Filter uncanny-learndash-toolkit

uo_toolkit_frontend_login_turnstile_key

Filters the Turnstile API key used for frontend login forms.

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

Description

This filter hook, `uo_toolkit_frontend_login_turnstile_key`, allows developers to dynamically modify the Turnstile site key used in the frontend login. It fires after the default key is retrieved, enabling customization for security or testing purposes. The hook receives the site key as its parameter.


Usage

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

Parameters

$key (mixed)
This parameter contains the Turnstile site key for the frontend login form.

Return Value

The filtered value.


Examples

/**
 * Example filter to modify the Turnstile site key for frontend login.
 * This example appends a suffix to the key if a specific condition is met.
 *
 * @param string $key The original Turnstile site key.
 * @return string The modified Turnstile site key.
 */
add_filter( 'uo_toolkit_frontend_login_turnstile_key', function( $key ) {
	// Check if the user is an administrator to apply a special key.
	if ( current_user_can( 'manage_options' ) ) {
		// In a real-world scenario, you might fetch a different key
		// from your settings for administrators or for testing purposes.
		// For this example, we'll just append a string.
		$key .= '_admin_override';
	}

	return $key;
}, 10, 1 ); // 10 is the priority, 1 is the number of arguments accepted.

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:392

public static function get_site_key() {

		$key = Config::get_settings_value( 'uo_frontend_login_turnstile_recaptcha_key', 'FrontendLoginPlus' );

		return apply_filters( 'uo_toolkit_frontend_login_turnstile_key', $key );
	}


Scroll to Top