uo_toolkit_two_factor_started
Fires after the two-factor authentication process has been successfully initiated.
add_action( 'uo_toolkit_two_factor_started', $callback, 10, 1 );
Description
Fired after the two-factor authentication process has begun for a user login. Developers can use this hook to perform actions immediately after the initial two-factor setup or verification stage is initiated.
Usage
add_action( 'uo_toolkit_two_factor_started', 'your_function_name', 10, 1 );
Examples
add_action( 'uo_toolkit_two_factor_started', function( $user_id, $provider ) {
// This action hook is fired when the two-factor authentication process has successfully started for a user.
// We can use this to log the event or trigger other related actions.
if ( ! $user_id || ! $provider ) {
error_log( 'uo_toolkit_two_factor_started: Missing user ID or provider.' );
return;
}
$user = get_user_by( 'id', $user_id );
if ( ! $user ) {
error_log( 'uo_toolkit_two_factor_started: User not found for ID: ' . $user_id );
return;
}
// Example: Log that two-factor authentication has started for a specific user and provider.
// In a real-world scenario, you might want to integrate with a logging system or trigger email notifications.
$log_message = sprintf(
'Two-factor authentication started for user "%s" (%d) using provider "%s".',
$user->user_login,
$user_id,
$provider
);
error_log( $log_message );
// You could also trigger other actions, for instance, to update user meta or send a notification.
// update_user_meta( $user_id, 'uo_2fa_last_started', current_time( 'mysql' ) );
}, 10, 2 ); // Priority 10, accepts 2 arguments: $user_id, $provider
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/includes/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-legacy.php:64
src/includes/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-2.6.php:83
src/includes/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-2-4.php:67
src/includes/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-2-3.php:65
src/includes/two-factor/providers/wp-2fa/legacy/class-frontend-login-plus-2fa-2-5.php:67
public function register_actions() {
if ( ! did_action( 'uo_toolkit_two_factor_started' ) ) {
// Set-up the action hooks.
add_action( 'init', array( $this, 'setup' ) );
do_action( 'uo_toolkit_two_factor_started' );
}
return true;
}