How to add captcha in contact us page in aroma?

7 answers

Profile photo of Ziven Staff 100440.00 $tone April 28, 2015

Find below steps to enable the Contact us form.
Step-1 : On the Admin menu, select System > Configuration.
Step-2 : In the panel on the left, under General, click Contacts.
Step-3 : Click to expand the Contact Us section, and set Enable Contact Us to Yes.
To Enable CAPTCHA, Follow the below steps
Step-1 : On the Admin menu, select System -> Configuration -> ADVANCED ->Admin.
Step-2 : Click to expand the CAPTCHA section, and Enable CAPTCHA in Admin to Yes. There you can find “Forms” and “Displaying Mode”, Find Below image for your reference
Step-3 : Under Forms, you could not find “Contact Us” form, To add Contact Us form, findcaptcha/forms element in core_config table and add “contact_form” form name to the list and modify config.xml in


in – <frontend><areas> add something like

<label>Contact Us</label>

Step-4 : and in – <always_for> add the below


Also there’s a miss for translation in the config file, so you should add this to the<frontend> section:


Step-5 : Refresh cache. Login to Admin, and make sure Contact Us form is listed in CAPTCHA configuration
Step-6 : Modify captcha layout xml file in frontend/base/default (or your theme) and add this section

<reference name=”contactForm”>
<block type=”core/text_list” name=””>
<block type=”captcha/captcha” name=”captcha”>
<reference name=”head”>
<action method=”addJs”>
<action method=”setFormId”>
<action method=”setImgWidth”>
<action method=”setImgHeight”>

and Refresh cache.
Step-7 : Modify form code in /frontend/base/default/template/contacts/form.phtml to add placeholder to render captcha layout .Add this line of code right before </ul>

<?php echo $this->getChildHtml(\\\’\\\’); ?>

Step-8 : Now, how to “trap” the post from the Contact Us form and check the captcha
Mage uses Events and Observer to achieve this, and it works very well for theforms/events they have implemented this feature. I was not able to find events specific for Contact Us form, so, IMHO the most obvious solution is to override indexController incode/core/Mage/Contacts/controllers and in the postAction method, inside try block add the following code:

$formId = ‘contact_form';
$captchaModel = Mage::helper(‘captcha’)->getCaptcha($formId);
if ($captchaModel->isRequired()) {
if (!$captchaModel->isCorrect($this->_getCaptchaString($this->getRequest(), $formId))) {
Mage::getSingleton(‘customer/session’)->addError(Mage::helper(‘captcha’)->__(‘Incorrect CAPTCHA.’));
$this->setFlag(”, Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);

and add this utility method to the controller class:

protected function _getCaptchaString($request, $formId)
$captchaParams = $request->getPost(Mage_Captcha_Helper_Data::INPUT_NAME_FIELD_VALUE);
return $captchaParams[$formId];

Step-9 : Refresh Cache, You are done.
Good Luck.

Profile photo of yasar arafath 70.00 $tone April 28, 2015

i have implement our code
i get this error
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in …/app/code/core/Mage/Contacts/controllers/IndexController.php on line 81
kindly help me
thanks in advance
regards -- yasar

Profile photo of yasar arafath 70.00 $tone April 28, 2015

 im solved the Error but it did not showing the captcha on contact page if im enable the testimonial submitting form its working good,captcha is showing ,but in a contact us page it did not show,
Kindly help me

Profile photo of yasar arafath 70.00 $tone April 28, 2015
Im find a solution for this
<?php echo $this->getChildHtml(\\\’\\\’); ?>
its not call a echo function

just make it to
<?php echo $this->getChildHtml(''); ?>
and also change the captcha layout xml file ” to "


Please login or Register to Submit Answer

Written By