Built-in reCAPTCHA module

Estimated reading time: 3 min

The reCAPTCHA module protects your site’s forms from spam and bots by adding Google reCAPTCHA to them. It covers your login, registration, lost password, comment and WooCommerce forms. You choose which version to use, add your Google keys, and pick which forms are protected.

There are two versions to choose from:

  • v2 (“I’m not a robot”) shows a checkbox, and sometimes an image challenge, that the visitor ticks before submitting the form.
  • v3 (invisible) runs silently in the background and scores each visitor from 0.0 (very likely a bot) to 1.0 (very likely a human), with no interaction needed.

Both are free and powered by Google.

Before you start: get your keys

reCAPTCHA needs a Site key and a Secret key from Google to work.

  1. Go to the reCAPTCHA admin console.
  2. Register your site and choose the version you want (v2 or v3). Choose the same version there that you will select in the settings below.
  3. Copy the Site key and the Secret key that Google gives you.

Keep in mind that v2 and v3 use different key pairs. A v3 secret key will not work with a v2 site key, and the other way around, so make sure both keys come from the same registration.

Enabling reCAPTCHA

  1. Go to your Theme Settings (Rey theme → Settings).
  2. Open the Advanced panel and click ReCaptcha.
  3. Set reCAPTCHA type to either Google reCAPTCHA v2 or Google reCAPTCHA v3.
  4. Paste in your Site key and Secret key.
  5. Choose which forms to protect (see below).

reCAPTCHA only becomes active once you have selected a type and filled in both keys. Until then, nothing is added to your forms.

Main settings

  • reCAPTCHA type — pick Disabled, Google reCAPTCHA v2, or Google reCAPTCHA v3. Setting this to Disabled turns the module off.
  • Site key — the public key Google generated for this site.
  • Secret key — the private key used to verify visitors with Google. Keep it secret.
  • v3 score threshold — only shown for v3. The minimum score a visitor must reach to pass, where 1.0 is very likely human and 0.0 is very likely a bot. The default of 0.5 is a balanced starting point. Raise it for stricter filtering, lower it if legitimate visitors are being blocked.
  • Lazy load (recommended) — loads the Google reCAPTCHA script only when a visitor first interacts with a form, instead of on every page load. This keeps it off the initial page load, so it does not hurt your PageSpeed score or Core Web Vitals. Leave it on unless you have a form that submits without any interaction. On by default.

Where to show

Turn reCAPTCHA on for each form individually:

  • Login Form — also covers the WooCommerce and Easy Digital Downloads login forms. On by default.
  • Registration Form — the WordPress user registration form. On by default.
  • Lost Password Form — the WordPress lost password form. On by default.
  • Comment Form — the WordPress comments form. Logged-in users are skipped automatically. On by default.
  • WooCommerce Registration Form — the registration form on the My Account page. Off by default. Only appears when WooCommerce is active.
  • WooCommerce Checkout Form — the checkout form. Off by default. Only appears when WooCommerce is active.

Locked out? Emergency off switch

If you enter a wrong key, reCAPTCHA can start rejecting everyone, including you, on the login form, which can lock you out of your own dashboard.

To recover, add this line to your wp-config.php file:

define('REYCORE_DISABLE_RECAPTCHA', true);

This turns off all captchas immediately, so you can log back in. Your settings stay intact, so once you are back in you can correct the keys and remove the line again.

Good to know

  • If Google’s servers cannot be reached during a check (for example a temporary Google outage), the module lets the submission through rather than blocking your visitors. This is intentional, so a Google problem can never lock users out.
  • Keys created through the Google Cloud console (reCAPTCHA Enterprise) are not the same as the classic keys this module uses. If verification keeps failing with a valid-looking key, open the key details in Google and use the “legacy secret key”, which is the one that works with the classic reCAPTCHA this module is built on.
  • A quick way to confirm everything is wired up correctly is to test with Google’s universal test keys, which always pass. If the widget shows and submits with those, the module is working and any failures are down to your real keys.

Was this article helpful?