reCAPTCHA Module designed for Magento CE 1.9.x and EE 1.14.x
- Copy the module into your Magento instance.
- Retrieve your public and private key at https://www.google.com/recaptcha/admin
- Add the keys to your magento configuration (under System > Configuration > sippsolutions > reCAPTCHA)
- It's done!
There are a few configuration options:
- Enable or disable the module
- Show the captcha for all visitors or only for guests
- You can switch between theme "light" and "dark"
- You can switch between size "normal" and "compact"
Currently the captcha gets integrated into:
- Login form
- Account register form
- Contact form
- Product review form
- You have the possibility to add your own routes
sippsolutions_recaptcha_solved
gets thrown when the captcha was successfully solved.
sippsolutions_recaptcha_redirect_before
gets thrown when the captcha was unfilled/outdated/incorrectly filled.
You can use sippsolutions.reCAPTCHA.reset()
to reset the captcha.
- jQuery must be integrated into Magento (CE 1.9+, EE 1.14+)
Tested with CE 1.9.2.2 and EE 1.14.2.1.
The module is free for private and commercial use (see LICENSE.txt).
Donations are greatly appreciated: https://www.paypal.me/sippert
When you use reCAPTCHA for ajax-based actions, you probably want to avoid the redirect.
Simply define a new event in your config.xml
, node config > global > events:
<sippsolutions_recaptcha_redirect_before>
<observers>
<your_module_captcha_ajax>
<class>your_module/observer</class>
<method>ajaxCaptchaFailed</method>
</your_module_captcha_ajax>
</observers>
</sippsolutions_recaptcha_redirect_before>
and use this as observer method in your Models/Observer.php
/**
* Captcha failed to verify
*
* @param Varien_Event_Observer $observer
*/
public function ajaxCaptchaFailed(Varien_Event_Observer $observer)
{
// get event
$event = $observer->getEvent();
// get config
$config = $event->getConfig();
// check on ajax
if (stripos($config->route, 'ajax') !== false) {
// set message
$config->shouldRedirect = false;
/** @var $controller Mage_Core_Controller_Front_Action */
$controller = $event->getController();
$controller->getResponse()->setBody(json_encode(array(
'success' => false,
'message' => $config->message,
)));
}
}