Free PrestaShop Captcha module
Do you manage a PrestaShop store? Have you been the victim of nasty spam on your Contact page?
This powerful PrestaShop Captcha Module brings you the solution!
PrestaShop Captcha Module installation and integration tutorial:
Step 1
Set up your Google reCAPTCHA account at https://www.google.com/recaptcha
Label: indicative name for the reCAPTCHA
Domains: indicate your domain name in the form "my-prestashop-store.com"
You will then have the API keys provided by Google!
Step 2
Download and install the PrestaShop Captcha Module.
Step 3
Configure the PrestaShop Captcha Module in the back office (your admin area)
and paste the public and secret keys provided by Google reCAPTCHA.
Step 4
Open the file www/themes/my-theme/contact-form.tpl and look for the following code (line 148 for PrestaShop 1.6.1.6):
<div class="submit">
<button type="submit" name="submitMessage" id="submitMessage" class="button btn btn-default button-medium"><span>{l s='Send'}<i class="icon-chevron-right right"></i></span></button>
</div>
Paste the following code just before replacing "YOUR_PUBLIC_KEY" with your public key provided by Google reCAPTCHA:
{if $captcha}
<script src='https://www.google.com/recaptcha/api.js'></script>
<div class="g-recaptcha" data-sitekey="YOUR_PUBLIC_KEY"></div>
{/if}
Save the file and send it back to the server using your FTP client.
Step 5
Open the file /controllers/front/ContactController.php
and just after this line:
$this->errors[] = Tools::displayError('Bad file extension');
add:
} else if (!($gcaptcha = (int)(Tools::getValue('g-recaptcha-response')))){
$this->errors[] = Tools::displayError('Captcha not verified');
}
Step 6
Refresh your Contact page and enjoy the result!