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:

  1. Log-in to your google account or register if you do not have one.
  2. Visit https://www.google.com/recaptcha/admin/create.
  3. Enter a name for your API key.
  4. Select “reCaptcha v2” > “I’m not a robot”.
  5. Enter your website domain name.
  6. Read and accept the Google reCaptcha terms.
  7. Submit the form.
  8. 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

F13 reCaptcha settings
Settings page for F13 reCaptcha.
Bespoke contact form
Example of a bespoke contact form built via F13 Email.

Installing

Installing is as simple as 1,2,3 –

Via WordPress

  1. Navigate to WP Admin > Plugins > Add New
  2. Search for “F13 reCaptcha”
  3. Install and activate

Manual

  1. Download the source code
  2. Upload the “f13-recaptcha” folder to your “wp-content/plugins” folder
  3. Activate the plugin in WP Admin > Plugins

GitHub

GitHub repository: f13dev/f13-recaptcha
Created: October 27, 2021 - 06:49pm
Last commit: October 30, 2021 - 09:12am
Forks: 0
Open issues: 0
Stars: 0
Watchers: 0
Description: N/A
git clone https://github.com/f13dev/f13-recaptcha

WordPress

Rating: (0/5 from 0 rating)
Description:Add Google reCaptcha to the comments section on blog posts. Requires Google reCaptcha v2 Checkbox API key. Simple configuration via the admin settings page: * reCaptcha public key * reCaptcha private ...
Tags:
captchacommentsrecaptchaspam
Downloads:507
Requirements
Version:1.0.0Requires WordPress:5.0+Tested with WordPress:5.8.10Requires PHP:+Created:October 30, 2021Last updated:October 30, 2021 5:15am

5 tags for "WordPress Plugin: reCaptcha"

No comments on WordPress Plugin: reCaptcha

Share your thoughts

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.