Filter uncanny-learndash-toolkit

uo_toolkit_frontend_login_turnstile_error_message_unchecked

Filters the error message displayed when the Turnstile checkbox is unchecked during frontend login.

add_filter( 'uo_toolkit_frontend_login_turnstile_error_message_unchecked', $callback, 10, 1 );

Description

Filters the error message displayed when the Turnstile (or reCAPTCHA) checkbox is unchecked during frontend login. Developers can modify this message to provide custom user guidance or translate it. This hook fires just before the error message is returned, allowing complete control over its content.


Usage

add_filter( 'uo_toolkit_frontend_login_turnstile_error_message_unchecked', 'your_function_name', 10, 1 );

Parameters

$error_message (mixed)
This parameter holds the error message displayed to the user when the Turnstile verification is not completed.

Return Value

The filtered value.


Examples

/**
 * Example of using the uo_toolkit_frontend_login_turnstile_error_message_unchecked filter.
 * This function customizes the error message displayed when the Turnstile checkbox is not checked.
 *
 * @param string $error_message The original error message.
 * @return string The modified error message.
 */
add_filter( 'uo_toolkit_frontend_login_turnstile_error_message_unchecked', function( $error_message ) {

	// Check if the current user is an administrator.
	// Administrators might prefer a more direct or technical error message.
	if ( current_user_can( 'administrator' ) ) {
		$error_message = __( 'Turnstile verification is required. Please confirm you are not a bot.', 'your-text-domain' );
	} else {
		// For regular users, keep a slightly friendlier message or add more context.
		$error_message = __( 'For your security, please complete the verification step to proceed.', 'your-text-domain' );
	}

	return $error_message;

}, 10, 1 ); // 10 is the priority, 1 is the number of arguments accepted by the callback.

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/classes/frontend-login/turnstile-support.php:455

public static function get_error_message_unchecked() {

		$error_message = Config::get_settings_value( 'uo_frontend_login_turnstile_recaptcha_empty_error', 'FrontendLoginPlus' );

		if ( empty( $error_message ) ) {
			$error_message = __( 'Please verify that you are not a robot.', 'FrontendLoginPlus' );
		}

		return apply_filters( 'uo_toolkit_frontend_login_turnstile_error_message_unchecked', $error_message );

	}


Scroll to Top