Get Free Audit

How to Enable CAPTCHA in Magento 2

Jun 21, 2019

12873 Andrey Litvin

How to Enable CAPTCHA in Magento 2

Discover what is Captcha and how to configure it in Magento online store. Get to know how to enable Magento Captcha programmatically and in the admin panel.

Nowadays people in different countries use the Internet for various purposes. They can sell and buy products online, pay with the help of Internet banking, etc. As their number continues to grow worldwide, it’s essential for ecommerce owners to take some measures to protect the personal database and private information from cyber attacks. To provide online safety we need some special programs. There are a great number of methods for providing online safety. But the most reliable and time-proved of them is CAPTCHA.

Do you know what is Captcha and why do websites need it? What are the main functions and features? What are the benefits of using Captcha? In this article we will learn about Captcha, how it works, can it prevent scammers, how to keep Captcha codes secure.

Table of contents:

What does Captcha mean?
Why is Captcha important for ecommerce?
How to configure Magento Captcha in the back office
How to enable Captcha in Magento customer registration form
How to add Magento Captcha to custom form
How to fix a not displaying Captcha?
Top 5 Magento Captcha extensions

What does Captcha mean?

The word CAPTCHA stands for Completely Automated Public Turing test to tell Computers and Humans Apart. It means that CAPTCHA helps to understand who the user actually is – a real person or a robot.

How can this program define it?  – Very simple. People are able to see the difference between numbers, letters and other symbols. So, CAPTCHA can do some manipulations with these signs to check if a user is able to determine them.

A robot can’t solve this problem and the program is very useful to prevent scammers and essential to protect personal or website data. So, CAPTCHA provides Internet safety and allows to feel protected and secure using different websites.

Let’s find out CAPTCHA functions and how it operates.

How does a Captcha work?

How does this program perform? What are its functions? The main purpose of CAPTCHA is to block spam software from posting comments on pages or buying too many products at once.

What are the most typical forms of Captcha?

  1. An image with a few distorted letters
  2. Choosing a common theme from different images

Why is Captcha important for ecommerce?

E-commerce websites usually use CAPTCHA to strengthen security around the most sensitive account access points.

At what points do online stores commonly implement CAPTCHA?

Let’s consider the most typical ones:

  1. Sign up for a new account or register
  2. Contact us
  3. Sign up for email newsletters
  4. Request a catalogue
  5. Login to make a purchase
  6. Get a quote

If your online shop is unprotected, you may have serious problems. For example, your customer and email databases will be full of spam email addresses. You will need much time and money to improve the situation.

migration to magento 2

Magento 2 Migration

Take your online store to the next level with BelVG Magento migration

Visit the page

How to keep Captcha codes secure?

If you decide to use a CAPTCHA code, you should take several measures.

  • Secure images
    Images must be distorted carelessly when presented to a person. Otherwise, they will be open to cyber attacks.
  • Unique CAPTCHAs
    Using similar codes can attract hackers. So, it’s essential to change the type of CAPTCHAs regularly and refuse from typical mathematical statements.
  • Script Security
    If you want to be protected from criminals, you shouldn’t forget about script security. Make sure that there are no easy ways around the script level.
  • Accessibility
    CAPTCHA should be available to everybody. That’s why users must have different opportunities from choosing images or reading texts to audio CAPTCHA.

How does Captcha prevent scammers?

Nowadays there are many cyber attacks and the Internet can not always be safe and secure for people. Hackers have a great number of scamming tactics and it is easy for them to trick Internet users. Cybercriminals started integrating CAPTCHA into their false websites to make their scams more trustworthy.

Is Captcha able to block scammers? What are its most beneficial functions?  Does it really provide Internet safety?

CAPTCHA protects:

  1. against email worms/junk mail
  2. email addresses from scammers
  3. website registration
  4. online polling

Moreover, CAPTCHA prevents dictionary attacks and comment spam on blogs.

We can see that there are a lot of helpful and useful functions which can help improve Internet safety and protect from cybercriminals.

magento development services

Magento Development Services

Take your online store to the next level with BelVG Magento development

Visit the page

Advantages of Captcha for ecommerce

Let’s consider CAPTCHA benefits for online business and why it should be used on websites. To understand if it is helpful for creating Internet safety, we will describe the main advantages and disadvantages.

Benefits of Captcha for an online store:

  1. Stops spam, generated by a bot, a script or a program
  2. Helps to decrease the amount of spam email
  3. Gives Internet users a high level of protection
  4. prevents comment spam (unwelcome messages and advertisements)
  5. stops fake registrations from bots

Challenges of Captcha:

  1. It doesn’t always identify real users from bots.
  2. It can block website spamming to an extent but it is presented to both the real users and bots.
  3. It enables to stop spam registrations from bots. But there are sophisticated bots that can bypass CAPTCHA.
  4. Sometimes it can be time-consuming and challenging. It can negatively impact online business because customers can be really annoyed by identifying difficult texts and images. And they may even choose the website without CAPTCHA.

So, we can see that CAPTCHA advantages outweigh the disadvantages. However, some online stores don’t use it because they don’t want to lose customers who can be frustrated by CAPTCHA.

How to configure Magento Captcha in the back office

Step #1: log in to Magento admin panel and navigate to Stores -> Settings.

stores settings

Step #2: select the store view you wish to configure CAPTCHA at.

select store view

Step #3: expand the Advanced tab, select Admin section and expand the Captcha section.

advanced captcha

Step #4: set up the fields as follows:

captcha settings

  • Enable CAPTCHA on Storefront – as Yes to enable; No to disable
  • Font
  • Forms – Admin Login or Admin Forgot Password
  • Displaying Mode – either Always, then captcha will be displayed every time, or After numbers of attempts to log in.
  • Number of Unsuccessful Attempts to Login – set up how many times the user needs to log in unsuccessfully so that the captcha would appear (the field appears if you select After numbers of attempts to log in in the previous filed).
  • CAPTCHA Timeout (minutes) – after how many minutes the captcha becomes invalid.
  • Number of Symbols – number of symbols in captcha (8 max)
  • Symbols Used in CAPTCHA – ABCDEFGHJKMnpqrstuvwxyz23456789
    Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed. Similar looking characters (e.g. “i”, “l”, “1”) decreases the chance of correct recognition by customer.
  • Case Sensitive – Yes or No.

Step #5: press Save Config button.

Andrey_Dubina

Partner With Us

Let's discuss how to grow your business. Get a Free Quote.
Talk to Andrey

How to enable Captcha in Magento customer registration form

Step #1: navigate to Stores -> Configuration.

stores settings

Step #2: expand the Customers tab and select Customer Configuration.

customers advanced

Step #3: expand the Captcha section and select Create user in Forms field.

captcha at registration form

Step #4: press Save Config button.

How to add Magento Captcha to custom form

There is no in-built functionality in Magento for adding a Captcha to the custom form. Therefore, we decided to approach this task creatively and decided to create a specialized module for this purpose. In this paragraph, we will describe how our custom module – Belvg_CaptchaForm – was created and how it functions.

Step #1: create the following config.xml in the etc folder of the module directory:


Step #2: define the form ID and its name in order to be able to activate it in the back office.

In our case, the form ID is captcha_form_1 and the form name is Custom Captcha Sample.

Now, if we navigate to Admin > Stores > Configuration > Customers > Customer Configuration > CAPTCHA, we will see our custom form in the Forms field.

custom captcha sample

Step #3: for convenience, let us make the Captcha open in a new window with the URL address /captchaForm:

In the module folder, create a view/frontend/layout subfolder. In the newly created subfolder, create captchaform_index_index.xml file with the following contents:


Step #4: create a controller to make a form available at  /captchaForm URL.

In the module folder, create a Controller/Index directory and place there the following Index.php:


Step #5: create a class for the Belvg\CaptchaForm\Block\CaptchaForm form block.

In the module folder Block, create a CaptchaForm.php file with the following contents:


Step #6: create a phtml template for our form in the  view/frontend/templates folder with the captcha_form.phtml name:


Now, as we follow the /captchaForm URL, we will get to out Captcha form page.

Step #7: create an action for form processing and make it pass validation:

In the etc folder, create an events.xml with the following contents:


Also, in the Observer folder, create the following CheckCaptchaFormObserver.php:


Step #8: create CaptchaFormPost action for form processing in the Controller/Index folder:


And we are finished! Now, as we visit the  /captchaForm link, we will see out custom form with a Captcha.

 

CLICK HERE TO EXPORT

Using the methods described above, it is possible to add Captcha to any form.

How to fix a not displaying Captcha?

In case the Captcha is not displaying after it was activated in the admin panel, here are three methods you can fix it:

Solution #1: Flush the cache by executing the cache:clean command and checking if the captcha block is enabled in CSS.

Solution #2: Check the Captcha’s Displaying Mode configuration in the admin panel.

Solution #3: Check the layout, in particular, whether there is a remove=”true” near the form.additional.info container or captcha attribute. In case if the not displaying Captcha is located at the checkout page, make sure that the captcha element does not have the following config:

Top 5 Magento Captcha extensions

In case you do not have time to make Captcha configurations, either programmatically or via back office, or simply do not wish to allocate your efforts to this aspect, but still want Magento Captcha enabled in your online store, there is a way out for you. Magento Marketplace offers a wide selection of free and paid extensions that provide for any need, and Captcha is not an exception.

Below you will find a comprehensive selection of 5 best Magento 2 Captcha extensions.

google_invisible_recaptcha_1_1_1_3Google Invisible reCaptcha.
This wonderfully functional module offers 3 forms of protections out-of-the-box – registration page, comments and reviews, and subscription page Captchas. In addition to the wide in-built functionality, it is also greatly configurable, enabling a store owner to add an invisible reCaptcha at any form in the Magento online store.
Compatibility: Community 2.1, 2.2, Enterprise , 2.1, 2.2
Price: $79.00

 

google-recaptchaGoogle reCaptcha by Mageplaza.
This free extension will provide your customers’ with a protective shield and secure their user experience at your Magento store by implementing an invisible Google reCaptcha. As a store manager, you get the possibility to add Captcha to any kinds of forms your store has, in particular, login and registration forms, contact us and change password pages, blog comments, FAQs, and any possible custom forms.
Compatibility: Community 2.1, 2.2, 2.3, Enterprise , 2.1, 2.2, 2.3
Price: Free

google_recaptchaGoogle reCAPTCHA by Azaleasoft.
The extension’s developers understood the importance of privacy for webstore security, and developed an extension that will successfully protect Magento store from bothering advertisements, fake registrations, email lists that are submitted through spamming and many other unwanted and potentially insecure things. It allows to enable Captcha for registration forms, login forms, password reset forms, contact-us forms and review forms.
Compatibility: Community 2.0, 2.1, 2.2
Price: $49.99

google-recaptcha-265x265_1_2Google reCAPTCHA by MageComp.
Prevent the spamming and secure your Magento store from malicious interventions with this Magento 2 extension. Implement Google reCaptcha for a variety of forms and pages that are common targets for scammers and hackers, like registration page, checkout page, subscription form and so on.
Compatibility: Community 2.1
Price: $25.99

 

recaptchaGoogle reCAPTCHA by Magesales.
This Google reCaptcha extension is simple to set up and intuitive to manage by a store admin. It is aimed at protecting your Magento store contact page from spam and bots, ensuring maximum security for your e-commerce. Google reCaptcha extension connects to reCaptcha library that ensures the needed level of captchas variety and complexity
Compatibility: Community 2, Enterprise 2
Price: $39.00

Wrapping up

So, we can tell that CAPTCHA is a good solution for providing online safety in e-commerce.

It has various advantages and disadvantages. It offers a great number of benefits in e-commerce like giving high level of protection of customers private information (Email addresses, phone numbers, passwords, etc), preventing spam messages or comments. On the other hand, sometimes it can be time-consuming and challenging for clients. And they can choose other websites.

In the article, we described how to set up and turn off Captcha in Magento, configure Magento CAPTCHA Settings for Admin and Customers.

In addition, we outlined Magento Captcha extensions, learnt how to add Captcha to Contact Us Page and to Custom Form, how to fix if it does not display.

If you have any questions, feel free to contact us.

magento development services

Magento Development Services

Take your online store to the next level with BelVG Magento development

Visit the page
Andrey Dubina
Partner With Us Looking for a partner to grow your business? We are the right company to bring your webstore to success. Talk to Andrey

2 Comments

  1. Yes, we also recognize the importance of CAPTCHA for Magento store functioning, that is why we created such a comprehensive guide over it.

  2. Security is one of the main aspects of every successful ecommerce store and in that case adding CAPTCHA is a useful practice.

    Thanks for sharing this great tutorial.

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *