- Added Dev_Reviewcaptcha.xml to etc/modules with the following:
Added Dev_Reviewcaptcha.xml to etc/modules with the following:
true local In app/code/local i added the following:
- 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>
- 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;
}
}
In design/frontend/default/celebrity/layout/ I added dev_reviewcaptcha.xml
mage/captcha.js review 230 50I added the following to the review product form
- getChildHtml('form.additional.info'); ?>