uo_toolkit_frontend_login_turnstile_is_active
Filters whether the Turnstile integration is active for frontend login forms on the current page load.
add_filter( 'uo_toolkit_frontend_login_turnstile_is_active', $callback, 10, 1 );
Description
This filter hook determines if Cloudflare Turnstile is active for frontend login forms. Developers can use this to programmatically enable or disable Turnstile based on custom conditions before the login form renders. It fires after site key and secret are checked, allowing conditional activation.
Usage
add_filter( 'uo_toolkit_frontend_login_turnstile_is_active', 'your_function_name', 10, 1 );
Parameters
-
$is_active(mixed) - This parameter is a boolean value indicating whether the Turnstile integration for frontend login is active, determined by the presence of both a site key and a site secret.
Return Value
The filtered value.
Examples
/**
* Example of how to hook into uo_toolkit_frontend_login_turnstile_is_active
* to conditionally disable Cloudflare Turnstile for the frontend login.
*
* This is useful for development environments or specific user roles
* where you might not want the Turnstile check to interfere.
*/
add_filter( 'uo_toolkit_frontend_login_turnstile_is_active', function( $is_active ) {
// Check if the current user is logged in and has the 'administrator' role.
// If so, disable Turnstile for this session.
if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
return false;
}
// Otherwise, return the original $is_active value.
return $is_active;
}, 10, 1 ); // Priority 10, accepts 1 argument
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:468
public static function turnstile_is_active() {
$is_active = ! empty( self::get_site_key() ) && ! empty( self::get_site_secret() );
return apply_filters( 'uo_toolkit_frontend_login_turnstile_is_active', $is_active );
}