A spam protector and form field using CloudFlare's Turnstile

Installs: 176

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 2

Forks: 0

Open Issues: 0


1.1.0 2023-05-08 13:15 UTC

This package is auto-updated.

Last update: 2023-09-08 13:56:45 UTC


Adds a "spam protection" field to SilverStripe userforms using Cloudflare's Turnstile service.

Maintainer Contact



composer require webbuilders-group/silverstripe-turnstile


There are multiple configuration options for the field, you must set the site_key and the secret_key which you can get from Cloudflare/. These configuration options must be added to your site's yaml config typically this is app/\_config/config.yml.

  default_spam_protector: WebbuildersGroup\Turnstile\Forms\TurnstileProtector  #Set the default spam protector

  site_key: '`TURNSTILE_SITE_KEY`' #Your site key (required)
  secret_key: '`TURNSTILE_SECRET_KEY`' #Your secret key (required)
  verify_ssl: true #Allows you to disable php-curl's SSL peer verification by setting this to false (optional, defaults to true)
  default_theme: "light" #Default theme color (optional, light, dark or auto, defaults to light)
  js_onload_callback: null #Onload callback to be called when the JS for Turnstile is loaded
  proxy_server: "`SS_OUTBOUND_PROXY_SERVER`" #Your proxy server address (optional)
  proxy_port: "`SS_OUTBOUND_PROXY_PORT`" #Your proxy server address port (optional)
  proxy_auth: "`SS_OUTBOUND_PROXY_AUTH`" #Your proxy server authentication information (optional)

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('Your description here');

Adding Custom Attributes

Turnstile has a few other options that this module does not out of the box provide hooks for setting, however you can set them your self using setAttribute for example:

          ->setAttribute('data-action', 'action')
          ->setAttribute('data-cdata', 'payload')
          ->setAttribute('data-callback', 'yourChallengeJSCallback')
          ->setAttribute('data-expired-callback', 'yourExpiredJSCallback')
          ->setAttribute('data-error-callback', 'youErrorJSCallback')
          ->setAttribute('data-tabindex', 0);