A spam protector extension using Google's reCAPTCHA 2

Installs: 32

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 1


dev-master 2020-01-01 00:49 UTC

This package is auto-updated.

Last update: 2020-08-24 18:57:31 UTC


license - bsd 3 clause Scrutinizer Code Quality Code Coverage Build Status Code Intelligence Status


Provides a FormField which allows form to validate for non-bot submissions using Google's reCAPTCHA v2 service.


  • SilverStripe Framework 4.0 or newer


Best installed via composer. You may clone the repo or download the zip, however you should find a directory called recaptcha with all files in your silverstripe root folder.

Using Composer

composer require kmedia/silverstripe-recaptcha

After installing the module via composer or manual install you must set the spam protector to ReCaptchaProtector, this needs to be set in your site's config file normally this is app/_config/mysite.yml.

  default_spam_protector: Kmedia\ReCaptcha\ReCaptchaProtector

Finally, add the "spam protection" field to your form fields.


You have to create your sitekey and secretkey in the environments (.env) file, which you can get from the reCAPTCHA page. These configuration options must be added to your site's yaml config typically this is app/_config/mysite.yml.

  theme: "light" #Default theme color (optional, light or dark, defaults to light)
  size: "normal" #Default size (optional, normal, compact or invisible, defaults to normal)
  badge: "bottomright" #Default badge position (bottomright, bottomleft or inline, defaults to bottomright)

Adding field labels

If you want to add a field label or help text to the Captcha field you can do so like this:

    ->setTitle("Spam protection")
    ->setDescription("Please tick the box to prove you're a human and help us stop spam.");