Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

frm_captcha_error_message

Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or third-party development.

Use the frm_captcha_error_message filter to change the message shown when a reCAPTCHA, hCaptcha, or Cloudflare Turnstile check fails. It receives the reason the CAPTCHA service gave and its error codes. Use them to show a different message for each kind of failure.

By default, the message doesn't say why the check failed. Telling a bot exactly why it was rejected helps it get past the next attempt. The one exception is a CAPTCHA that isn't set up correctly on your site, because a visitor can't fix that by trying again.

Requirements

  • Formidable Forms 7.0 or later.
  • The filter is in Formidable Forms Lite, so it works with or without Formidable Forms Pro.
  • A CAPTCHA field on the form, with keys saved in Formidable → Global Settings → Captcha/Spam.

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

Usage

add_filter( 'frm_captcha_error_message', 'my_captcha_error_message', 10, 4 );

Parameters

  • $message (string): The message shown on the CAPTCHA field. By default, this is the Invalid Format message in the field's Validation Messages options, or "The CAPTCHA was not entered correctly" when that box is empty. When the error codes show a site setup problem, it's "The CAPTCHA on this form is not set up correctly. Please contact the site administrator."
  • $reason (string): A readable explanation of the failure, such as "The CAPTCHA response expired or was already used." For reCAPTCHA v3, it can also say that the score was below your threshold.
  • $error_codes (array): The error codes returned by the CAPTCHA service, such as 'timeout-or-duplicate' or 'invalid-input-secret'. It can be empty.
  • $field (array|object): The CAPTCHA field.

When the filter runs

The filter runs when the CAPTCHA service rejects a response, including a reCAPTCHA v3 score below the threshold. It doesn't run when the form is submitted without a CAPTCHA response, or when your site can't reach the CAPTCHA service. Those failures use their own messages.

The filtered message appears when the CAPTCHA errors spam check is set to Reject with an error message, which is the default.

When it's set to Save as a spam entry, a new submission is saved as a spam entry and no error is shown. When an existing entry is edited, the error still shows. Learn more about spam checks.

Examples

Learn where to put the code when adding a custom PHP function to your site.

Ask visitors to retry an expired CAPTCHA

A CAPTCHA response can expire before the form is submitted. This example shows a clearer message for that case. It checks the expired-response codes used by reCAPTCHA, Cloudflare Turnstile, and hCaptcha.

add_filter( 'frm_captcha_error_message', 'my_captcha_expired_message', 10, 3 );
function my_captcha_expired_message( $message, $reason, $error_codes ) {
	$expired_codes = array( 'timeout-or-duplicate', 'invalid-or-already-seen-response' );

	if ( array_intersect( $expired_codes, $error_codes ) ) {
		$message = 'The CAPTCHA expired. Please complete it again and resubmit the form.';
	}

	return $message;
}

Show the reason to site administrators

This example adds the reason to the message when a logged-in administrator submits the form. It helps you test a form without showing the reason to everyone else.

add_filter( 'frm_captcha_error_message', 'my_show_captcha_reason_to_admins', 10, 2 );
function my_show_captcha_reason_to_admins( $message, $reason ) {
	if ( $reason && current_user_can( 'manage_options' ) ) {
		$message .= ' ' . $reason;
	}

	return $message;
}

Limitations

  • Showing the reason to every visitor also shows it to bots. Instead, keep the detailed reason for administrators or for your own logs.
  • The error codes differ between CAPTCHA services. In your function, check for every code you want to handle.
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2026 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Don't forget your purchase!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms