Download the PHP package matt-west/craft-recaptcha without Composer
On this page you can find all versions of the php package matt-west/craft-recaptcha. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download matt-west/craft-recaptcha
More information about matt-west/craft-recaptcha
Files in matt-west/craft-recaptcha
Package craft-recaptcha
Short Description Integrate Google’s reCAPTCHA into your forms.
License MIT
Informations about the package craft-recaptcha
Craft reCAPTCHA plugin for Craft CMS 4.x
Integrate Google’s reCAPTCHA into your forms. Includes support for the CraftCMS Contact Form plugin.
Requirements
This plugin requires Craft CMS 5 or later.
This plugin supports reCAPTCHA v2 only.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require matt-west/craft-recaptcha
- In the Control Panel, go to Settings → Plugins and click the “Install” button for Craft reCAPTCHA.
Configuring Craft reCAPTCHA
- Sign up for reCAPTCHA API key.
- Open the Craft admin and go to Settings → Plugins → Craft reCAPTCHA → Settings.
- Add your
site key
andsecret key
, then save. - Add the reCAPTCHA template tag to your forms. (see next section)
If you’re using the CraftCMS Contact Form plugin, everything is already set up for you.
Verify the reCAPTCHA
To verify the reCAPTCHA is valid, pass the reCAPTCHA response from the g-recaptcha-response
param to the verify()
method on CraftRecaptcha::$plugin->craftRecaptchaService
.
Or alternatively, use the in-built verification controller action to verify the request before forwarding it on to the intended action.
For example, the following fields would verify the reCAPTCHA and then pass the request to the login controller action:
Set the action
field to be recaptcha/recaptcha/verify-submission
and the verified-action
field to be the intended controller action you want to trigger. This will forward all other fields and parameters to the intended controller action.
Automated testing and reCAPTCHA
If you need to run automated tests against your forms use the following keys. Verification requests using these credentials will always pass.
Site key: 6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
Secret key: 6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
Using Craft reCAPTCHA
Add the following tag to your form where you’d like the reCAPTCHA to be displayed.
Render parameters per the documentation are injectable to the render()
function, e.g.
You can also create the reCAPTCHA element yourself using the sitekey
template variable. This is especially useful for implementing invisible recaptcha.
Brought to you by Matt West