uo_toolkit_frontend_login_lost_password_before
Fires before the lost password form is displayed on the frontend, allowing for modifications.
add_action( 'uo_toolkit_frontend_login_lost_password_before', $callback, 10, 1 );
Description
Fires before the password reset process begins for the frontend login. Developers can use this hook to add custom actions, modify validation logic, or enqueue scripts before the password reset email is sent. It's a critical point for customizing the lost password flow.
Usage
add_action( 'uo_toolkit_frontend_login_lost_password_before', 'your_function_name', 10, 1 );
Examples
/**
* Example function to hook into 'uo_toolkit_frontend_login_lost_password_before'.
* This example demonstrates how to modify the password reset process or
* add custom logic before the standard password reset actions are performed.
*
* @since 3.3
*/
function my_custom_lost_password_hook_before() {
// Example: Check if the user is logged in (though this hook is typically for logged-out users).
// If for some reason a logged-in user is in this flow, we might want to log it or redirect them.
if ( is_user_logged_in() ) {
// Log a message or perform some action if a logged-in user reaches this point unexpectedly.
error_log( 'Unexpected logged-in user attempting password reset via frontend login.' );
// Optionally, you could set a flag or add data to the $response array that the
// main function might consume. Since this is an action hook, we can't directly
// modify the $response array that is initialized in `uo_lostPass_action()`.
// However, we can use global variables or transient data if needed, though
// for this specific hook, directly modifying $response is not possible.
// If the goal is to prevent the reset, a filter hook would be more appropriate.
}
// Example: Add custom data to a transient for later use in the process.
// This is just a demonstration; the actual use case would depend on the plugin's architecture.
$transient_key = 'my_custom_lost_password_data_' . uniqid();
$custom_data = array(
'timestamp' => time(),
'source' => 'my_custom_hook',
);
set_transient( $transient_key, $custom_data, 5 * MINUTE_IN_SECONDS ); // Store for 5 minutes.
// Example: Trigger another action for further customization.
do_action( 'my_custom_frontend_login_before_password_reset_step', $transient_key );
}
// Add the action hook.
// The function `uo_lostPass_action` in the source does not pass any arguments to the hook.
// Therefore, we specify 0 for the accepted arguments.
add_action( 'uo_toolkit_frontend_login_lost_password_before', 'my_custom_lost_password_hook_before', 10, 0 );
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-plus.php:3469
*
* @since 3.3
*/
public static function uo_lostPass_action() {
$response = array();
$response_code = 200;
do_action( 'uo_toolkit_frontend_login_lost_password_before' );
// Validate ajax call here.
/*
if( ! check_ajax_referer('uncannyowl-learndash-toolkit','nonce') ) {
$response['success'] = false;
$response['message'] = esc_html__( 'Something went wrong. Please, try again', 'uncanny-learndash-toolkit' );
self::wp_send_json( $response, $response_code );