Download the PHP package undefinedoffset/silverstripe-nocaptcha without Composer
On this page you can find all versions of the php package undefinedoffset/silverstripe-nocaptcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download undefinedoffset/silverstripe-nocaptcha
More information about undefinedoffset/silverstripe-nocaptcha
Files in undefinedoffset/silverstripe-nocaptcha
Package silverstripe-nocaptcha
Short Description A spam protector and form field using Google's reCAPTCHA v2 or optionally a foundation v3 implementation
License BSD-3-Clause
Informations about the package silverstripe-nocaptcha
Nocaptcha
Adds a "spam protection" field to SilverStripe userforms using Google's reCAPTCHA service.
Requirements
- SilverStripe ^4 | ^5
- SilverStripe Spam Protection ^2 | ^3
- PHP CURL
Installation
After installing the module via composer or manual install you must set the spam protector to NocaptchaProtector, this needs to be set in your site's config file normally this is mysite/_config/config.yml.
Finally, add the "spam protection" field to your form by calling
enableSpamProtection()
on the form object.
Configuration
There are multiple configuration options for the field, you must set the site_key and the secret_key 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/config.yml.
Adding field labels
If you want to add a field label or help text to the Captcha field you can do so like this:
Commenting Module
When your using the silverstripe/comments module you must add the following (per their documentation) to your _config.php in order to use nocaptcha/spamprotection on comment forms.
Retrieving the Verify Response
If you wish to manually retrieve the Site Verify response in you form action use
the getVerifyResponse()
method
ReCAPTCHA v3
ReCAPTCHA v3 is different to v2, users won't be presented with a "Are you a robot?" checkbox, instead user actions are returned a spam score 0.0 to 1.0 when they submit the form. Out of the box, this module will block any submission with a spam score of <= 0.4 but this can be tailored either site-wide using the Config API
Or on a per form basis:
For more information about version 3, including how to implement custom actions see https://developers.google.com/recaptcha/docs/v3
Handling form submission
By default, the javascript included with this module will add a submit event handler to your form.
If you need to handle form submissions in a special way (for example to support front-end validation), you can choose to handle form submit events yourself.
This can be configured site-wide using the Config API
Or on a per form basis:
With this configuration no event handlers will be added by this module to your form. Instead, a
function will be provided called nocaptcha_handleCaptcha
which you can call from your code
when you're ready to submit your form. It has the following signature:
form
must be the form element, and callback
should be a function that finally submits the form,
though it is optional.
In the simplest case, you can use it like this:
Reporting an issue
When you're reporting an issue please ensure you specify what version of SilverStripe you are using i.e. 3.1.3, 3.2beta, master etc. Also be sure to include any JavaScript or PHP errors you receive, for PHP errors please ensure you include the full stack trace. Also please include how you produced the issue. You may also be asked to provide some of the classes to aid in re-producing the issue. Stick with the issue, remember that you seen the issue not the maintainer of the module so it may take allot of questions to arrive at a fix or answer.