Introduction
Add Google reCaptcha to comments forms on posts and pages. Additional filters are included for programmers to add reCaptcha to forms with ease
Filters
As a site owner or developer it is frustrating having to store multiple copies of the same API key, for example if you were to have separate reCaptcha plugins for comments and contact forms. For this reason hooks have been included allowing integrations with F13 reCaptcha from other plugins.
Adding reCaptcha
Adding a Google reCaptcha checkbox via filters can be achieved simply.
$v = '<form>';
// Form fields
$v .= apply_filters('f13_recaptcha_add');
$v .= '<input type="submit" value="submit">';
$v .= '</form>';
return $v;
Using the above code as an example, a Google reCaptcha checkbox will now be shown on the form. If you are unable to see the reCaptcha, it may be due to the visibility setting in the admin panel, try setting this to “Everybody”.
Validating reCaptcha
Similar to adding the reCaptcha checkbox, validation is achieved via a filter. The validation filter returns:
- An empty string if validation passes
- An error message if validation fails
$msg = '';
$recaptcha = apply_filters('f13_recaptcha_validate');
if (!empty($recaptcha)) {
// reCaptcha has failed, show an error message
$msg = $recaptcha;
} else {
// reCaptcha has passed
// Continue validation of other fields
$msg = 'Success';
}
return $msg;
Configuration
In order for F13 reCapthca to operate, a Google reCapcha V2 Checkbox API key is required.
To obtain a Google reCaptcha API key:
- Log-in to your google account or register if you do not have one.
- Visit https://www.google.com/recaptcha/admin/create.
- Enter a name for your API key.
- Select “reCaptcha v2” > “I’m not a robot”.
- Enter your website domain name.
- Read and accept the Google reCaptcha terms.
- Submit the form.
- Copy and paste the public and private API keys to the appropriate fields in “F13 Admin” > “Google reCaptcha”.
Google reCaptcha can be enabled for:
- Everyone
- Non logged in users (visitors)
- Nobody (disabled)
Screenshots
Installing
Installing is as simple as 1,2,3 –
Via WordPress
- Navigate to WP Admin > Plugins > Add New
- Search for “F13 reCaptcha”
- Install and activate
Manual
- Download the source code
- Upload the “f13-recaptcha” folder to your “wp-content/plugins” folder
- Activate the plugin in WP Admin > Plugins
GitHub
Last commit: October 30, 2021 - 09:12am
Forks: 0
Open issues: 0
Stars: 0
Watchers: 0
No comments on WordPress Plugin: reCaptcha