ReCaptcha

This module allow you to add easily a reCAPTCHA to your form

Installation

Composer

Add it in your main thelia composer.json file

composer require thelia/re-captcha-module:~1.0

Usage

Before using this module you have to create google api key here http://www.google.com/recaptcha/admin next configure your reCAPTCHA access here /admin/module/ReCaptcha` then you'll need help from a developer to add some hooks in template and dispatch check event

Hook

First if you don't have {hook name="main.head-top"} hook in your template you have to put this hook {hook name="recaptcha.js"} in the top of your head After that you have the choice between two type of captcha :

  1. A standard captcha

Checkbox captcha

In this case you have just to put this hook {hook name="recaptcha.v2.button"} in form where you want to use captcha

  1. The new invisible captcha

Invisible captcha

In this case you'll have a bit more to do :

  • Add this class captcha-form to the form
  • Add this class g-recaptcha to the submit button and this hook {hook name="recaptcha.invisible.button"} in the tag like this <button class="btn btn-primary g-recaptcha" {hook name="recaptcha.invisible.button"}>Validate</button>

Event

To check in server-side if the captcha is valid you have to dispatch the "CHECK_CAPTCHA_EVENT" like this :

$checkCaptchaEvent = new ReCaptchaCheckEvent();
$this->dispatch(ReCaptchaEvents::CHECK_CAPTCHA_EVENT, $checkCaptchaEvent);

Then the result of check is available in $checkCaptchaEvent->isHuman()as boolean so you can do a test like this :

if ($checkCaptchaEvent->isHuman() == false) {
    throw new \Exception('Invalid captcha');
}
Download
recaptcha.gif Download

ReCaptcha

This module allow you to add easily a reCAPTCHA to your thelia form

Say Hi & Get in Touch

info@thelia.net - +33(0)4 44 05 31 00

Thelia Network English
E-commerce solution

E-commerce software, useful to create and manage online stores, published under a free license. Discover our new version, based on many modern technologies !

Download Thelia
Business

A team of experts at your service.

Showcase

Over 7000 online stores powered by Thelia

Modules

Customize your Thelia.

Openstudio

Thelia editor