Web design company India | Custom web development company India
open

3 Simple Steps to enable Magento Captcha in contact us form and Custom Forms

  • “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 idrive.com 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 supports developers to secure user documents from Hackers.

     

    Magento Captcha in Contact Us form and Custom Forms

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

    let's follow the Magento development companies instructions step by step.

    Step by step  to Enable Magento Captcha

    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

      1 

    Refresh the page so that you can see that Magento 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('form.additional.info'); ?> 

    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 “ form.additional.info”  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 to add captcha in our custom form say in  a  “quote” form, follow the steps,

    Step 1

    Add the “quote” form under the forms section.

      1 

    Step 2

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

     getChildHtml('form.additional.info'); ?> 

    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



  • Post Comments

    Submit Comment




    * Required Fields