Captcha not showing on frontend login page. It works fine on register and forgot password section. I am using default template captcha module in rwd template. Following all the necessary changes. Guide me from this problem. I am using magento 1.9.2.2.
2 Answers
Login to backend Go to system > configuration > customers > customer configuration > CAPTCHA
and select your website scope
Enable CAPTCHA
on frontend - Yes
Select all forms into Form box
In Displaying Mode box select After number of attempts to login
Set Number of Unsuccessful Attempts to Login
= 0
Save Config
Go to frontend and press Log in link to show the captcha form.
Please use the following code for google invisible captcha. The spam emails are bypassing the old Magento inbuilt captcha. The following code will do the server side validation.
<?php class Addpeople_Validatecaptcha_Model_Customer_Customer extends Mage_Customer_Model_Customer {
public function validate()
{
$errors = array();
if (!Zend_Validate::is( trim($this->getFirstname()) , 'NotEmpty')) {
$errors[] = Mage::helper('customer')->__('The first name cannot be empty.');
}
if (!Zend_Validate::is( trim($this->getLastname()) , 'NotEmpty')) {
$errors[] = Mage::helper('customer')->__('The last name cannot be empty.');
}
if (!Zend_Validate::is($this->getEmail(), 'EmailAddress')) {
$errors[] = Mage::helper('customer')->__('Invalid email address "%s".', $this->getEmail());
}
$password = $this->getPassword();
if (!$this->getId() && !Zend_Validate::is($password , 'NotEmpty')) {
$errors[] = Mage::helper('customer')->__('The password cannot be empty.');
}
if (strlen($password) && !Zend_Validate::is($password, 'StringLength', array(self::MINIMUM_PASSWORD_LENGTH))) {
$errors[] = Mage::helper('customer')
->__('The minimum password length is %s', self::MINIMUM_PASSWORD_LENGTH);
}
if (strlen($password) && !Zend_Validate::is($password, 'StringLength', array('max' => self::MAXIMUM_PASSWORD_LENGTH))) {
$errors[] = Mage::helper('customer')
->__('Please enter a password with at most %s characters.', self::MAXIMUM_PASSWORD_LENGTH);
}
$confirmation = $this->getPasswordConfirmation();
if ($password != $confirmation) {
$errors[] = Mage::helper('customer')->__('Please make sure your passwords match.');
}
$entityType = Mage::getSingleton('eav/config')->getEntityType('customer');
$attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'dob');
if ($attribute->getIsRequired() && '' == trim($this->getDob())) {
$errors[] = Mage::helper('customer')->__('The Date of Birth is required.');
}
$attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'taxvat');
if ($attribute->getIsRequired() && '' == trim($this->getTaxvat())) {
$errors[] = Mage::helper('customer')->__('The TAX/VAT number is required.');
}
$attribute = Mage::getModel('customer/attribute')->loadByCode($entityType, 'gender');
if ($attribute->getIsRequired() && '' == trim($this->getGender())) {
$errors[] = Mage::helper('customer')->__('Gender is required.');
}
if( Mage::getStoreConfig('validate_captcha/server_side_validation/enabled') ) {
$errors = $this->validateCaptcha($errors);
}
if (empty($errors)) {
return true;
}
return $errors;
}
private function validateCaptcha( $errors ) {
/* additional reCAPTCHA validation */
$action = Mage::app()->getRequest()->getActionName();
if ( $action == 'createpost' ) {
$captcha = Mage::app()->getRequest()->getPost('g-recaptcha-response', 1);
if ( $captcha == '' ) {
$errors[] = Mage::helper('customer')->__('Please check the reCAPTCHA field to continue.');
} else {
$params = array();
$params['secret'] = Mage::getStoreConfig('validate_captcha/server_side_validation/secret_key');
$params['response'] = Mage::app()->getRequest()->getPost('g-recaptcha-response', 1);
$params['remoteip'] = $_SERVER['REMOTE_ADDR'];
$params_string = http_build_query($params);
$url = 'https://www.google.com/recaptcha/api/siteverify?'.$params_string;
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
$result = json_decode( $response, true );
if ( trim( $result['success'] ) != true ) {
// This will be shown at the top of the registration page
$errors[] = Mage::helper('customer')->__('reCAPTCHA unable to verify.');
}
}
}
} }
Please refer my website for layout and config file details. https://www.pearlbells.co.uk/invisible-recaptcha-register-form-magento/