How to enable Magento Captcha in contact us form?

How to enable Magento Captcha in contact us form?

Magento Captcha in Contact us form

This blog describes how to add Magento Captcha in contact us form

“Have you ever wondered! what’s the box that appears at end of most logins? Although we are users, why is that done so???”

It is nothing but known as reCaptcha/Captcha, which is a kind of a challenge to determine whether or not the user is a Human.

Internet users in early days have wanted to make text illegible to computers. The first such people were Hackers.

They used internet forums as there medium of posting sensitive topics, which were automatically monitored for keywords.

To Circumvent these kinds of hazards they used an encryption method Known as Leetspeak. It converts the words to symbols, numeric, words etc…

eg:- HAI can be changed to (2#a) or (at5) etc..

This technique was first introduced in in 2000, on their signup page. Later in 2009, deployment of Captcha, reCaptcha was acquired by Google. 

After the acquisition, Google had developed Captcha with image verification, which we see today. Coming to Modern world, Captcha also serves with a benchmark task for artificial intelligence technologies.

Coming to the Development side of Magento services, captcha magento contact form supports developers to secure user documents from Hackers.


Magento Captcha

Here we are integrating our customs form with Magento's Contact Form Captcha,

let's follow the Magento Development Company experts instructions.

Step by step to add magento captcha to contact form

Step 1

First, add captcha block to contacts form and add this code to local.xml

 mage/captcha.js contacts 230 50 

Step 2

Go to admin → customers → customer configuration → captcha

On enabling captcha, a forms field will appear as shown below.

Add the contacts form under the forms section as shown in the above image. Add the following code to the config.xml file


Refresh the page so that you can see that Magento 2 Captcha Contact form page is added to the forms section

Step 3

Finally, call the Magento captcha block in phtml file. Add this code to contact.phtml file

 getChildHtml(''); ?> 

That's it! we have added Magento 2 add captcha to contacts form as shown below.

Magento Captcha in Custom Forms

In some cases, we cannot call the “”  as a child block in our phtml file. In that case, we can add captcha by calling the singleton to get the captcha block object in corresponding phtml file.

For eg: if require magento add captcha to custom form say in  a  “quote” form, follow the steps,

Step 1

Add the “quote” form under the forms section.


Step 2

Call the singleton to have the block object of captcha in the phtml file.

 getChildHtml(''); ?> 

That's it! Captcha will be displayed in “quote” form.

We can reduce the lines in captcha by overriding lib → Zend → captcha → Image.php and change the protected $_dotNoiseLevel and protected $_lineNoiseLevel values.

Give a comment below if this step helps to add Magento Captcha in Contact us Form and Custom Form

  • Share on Facebook
  • Share on Twitter
  • Share on LinkedIn
  • Youtube

leave a comment