Skip to main content
  1. Added Dev_Reviewcaptcha.xml to etc/modules with the following:

    Added Dev_Reviewcaptcha.xml to etc/modules with the following:

    true local
  2. In app/code/local i added the following:

truelocal
  1. In app/code/local i added the following:
0.0.1Dev_Reviewcaptcha_Modelreviewcaptcha/observercheckReviewCaptchadev_reviewcaptcha.xmlProduct Review1
<?xml version="1.0"?>
 <config>
  <modules>
   <Dev_Reviewcaptcha>
    <version>0.0.1</version>
   </Dev_Reviewcaptcha>
  </modules>
  <global>
   <models>
    <reviewcaptcha>
     <class>Dev_Reviewcaptcha_Model</class>
    </reviewcaptcha>
   </models>
   <events>
    <controller_action_predispatch_review>
     <observers>
      <reviewcaptcha>
       <class>reviewcaptcha/observer</class>
       <method>checkReviewCaptcha</method>
      </reviewcaptcha>
     </observers>
    </controller_action_predispatch_review>
   </events>
  </global>
  <frontend>
   <layout>
    <updates>
     <reviewcaptcha>
      <file>dev_reviewcaptcha.xml</file>
     </reviewcaptcha>
    </updates>
   </layout>
  </frontend>
  <default>
   <captcha>
    <frontend>
     <areas>
      <review>
       <label>Product Review</label>
      </review> 
     </areas>
    </frontend>
   </captcha>
   <customer>
    <captcha>
     <always_for>
      <review>1</review>
     </always_for>
    </captcha>
   </customer>
  </default>
</config>
getCaptcha($formId);if($captchaModel->isRequired()){$controller = $observer->getControllerAction();if(!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))){Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));$controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);$controller->getResponse()->setRedirect(Mage::getUrl('/'));}}return $this;}}3) In design/frontend/default/celebrity/layout/ I added dev_reviewcaptcha.xmlmage/captcha.jsreview23050
  1. I added the following to the review product form
<?php
 class Dev_Reviewcaptcha_Model_Observer extends Mage_Captcha_Model_Observer
 {
  public function checkReviewCaptcha($observer) { 
   $formId = 'review';
   $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
   if ($captchaModel->isRequired()) {
    $controller = $observer->getControllerAction();
    if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
     Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect    CAPTCHA.'));
     $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
     $controller->getResponse()->setRedirect(Mage::getUrl('/'));
    }
   }
   return $this;
 }
}
  • getChildHtml('form.additional.info'); ?>
    1. In design/frontend/default/celebrity/layout/ I added dev_reviewcaptcha.xml

      mage/captcha.js review 230 50
    2. I added the following to the review product form

    3. getChildHtml('form.additional.info'); ?>
    1. Added Dev_Reviewcaptcha.xml to etc/modules with the following:
    truelocal
    1. In app/code/local i added the following:
    0.0.1Dev_Reviewcaptcha_Modelreviewcaptcha/observercheckReviewCaptchadev_reviewcaptcha.xmlProduct Review1
    getCaptcha($formId);if($captchaModel->isRequired()){$controller = $observer->getControllerAction();if(!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))){Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.'));$controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);$controller->getResponse()->setRedirect(Mage::getUrl('/'));}}return $this;}}3) In design/frontend/default/celebrity/layout/ I added dev_reviewcaptcha.xmlmage/captcha.jsreview23050
    1. I added the following to the review product form
  • getChildHtml('form.additional.info'); ?>
    1. Added Dev_Reviewcaptcha.xml to etc/modules with the following:

      true local
    2. In app/code/local i added the following:

    <?xml version="1.0"?>
     <config>
      <modules>
       <Dev_Reviewcaptcha>
        <version>0.0.1</version>
       </Dev_Reviewcaptcha>
      </modules>
      <global>
       <models>
        <reviewcaptcha>
         <class>Dev_Reviewcaptcha_Model</class>
        </reviewcaptcha>
       </models>
       <events>
        <controller_action_predispatch_review>
         <observers>
          <reviewcaptcha>
           <class>reviewcaptcha/observer</class>
           <method>checkReviewCaptcha</method>
          </reviewcaptcha>
         </observers>
        </controller_action_predispatch_review>
       </events>
      </global>
      <frontend>
       <layout>
        <updates>
         <reviewcaptcha>
          <file>dev_reviewcaptcha.xml</file>
         </reviewcaptcha>
        </updates>
       </layout>
      </frontend>
      <default>
       <captcha>
        <frontend>
         <areas>
          <review>
           <label>Product Review</label>
          </review> 
         </areas>
        </frontend>
       </captcha>
       <customer>
        <captcha>
         <always_for>
          <review>1</review>
         </always_for>
        </captcha>
       </customer>
      </default>
    </config>
    
    <?php
     class Dev_Reviewcaptcha_Model_Observer extends Mage_Captcha_Model_Observer
     {
      public function checkReviewCaptcha($observer) { 
       $formId = 'review';
       $captchaModel = Mage::helper('captcha')->getCaptcha($formId);
       if ($captchaModel->isRequired()) {
        $controller = $observer->getControllerAction();
        if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
         Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect    CAPTCHA.'));
         $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true);
         $controller->getResponse()->setRedirect(Mage::getUrl('/'));
        }
       }
       return $this;
     }
    }
    
    1. In design/frontend/default/celebrity/layout/ I added dev_reviewcaptcha.xml

      mage/captcha.js review 230 50
    2. I added the following to the review product form

    3. getChildHtml('form.additional.info'); ?>
    Source Link

    Magento 1.9.2.4 Custom Captcha not displaying

    First of all thank you so much for your time.

    I am having an issue, I need to add the captcha field to the review product form. The weird part is that when the form is submitted, the captcha is validated and I get the error message, Invalida captcha, but the captcha input, image and refresh button are not displayed in the form.

    I added the following, but I am confused on 2 things:

    In the config.xml we have the controller_action_predispatch_review but I don't know how to name it exactly, based on what, also in the same file, we have frontend->layout->updates and then the following node is "reviewcaptcha" but not sure as well how that node has to be named, the last one, is the formId name, in this example is review since It's the same name that I am using in the node after frontend:

    Product Review . . .
    1. Added Dev_Reviewcaptcha.xml to etc/modules with the following:
    true local
    1. In app/code/local i added the following:

    a) Dev/Reviewcaptcha/etc/config.xml

    0.0.1 Dev_Reviewcaptcha_Model reviewcaptcha/observer checkReviewCaptcha dev_reviewcaptcha.xml Product Review 1

    b) Dev/Reviewcaptcha/Model/Observer.php

    getCaptcha($formId); if ($captchaModel->isRequired()) { $controller = $observer->getControllerAction(); if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) { Mage::getSingleton('customer/session')->addError(Mage::helper('captcha')->__('Incorrect CAPTCHA.')); $controller->setFlag('', Mage_Core_Controller_Varien_Action::FLAG_NO_DISPATCH, true); $controller->getResponse()->setRedirect(Mage::getUrl('/')); } } return $this; } } 3) In design/frontend/default/celebrity/layout/ I added dev_reviewcaptcha.xml mage/captcha.js review 230 50
    1. I added the following to the review product form
  • getChildHtml('form.additional.info'); ?>