Action uncanny-learndash-toolkit

uo_forgot_after_success

Fires after a user successfully requests a password reset.

add_action( 'uo_forgot_after_success', $callback, 10, 1 );

Description

Fires after a successful password reset request. Developers can use this hook to perform custom actions, like logging the event, sending additional notifications, or modifying the user interface after the success message is displayed. This hook is triggered within the template files for password reset forms.


Usage

add_action( 'uo_forgot_after_success', 'your_function_name', 10, 1 );

Examples

<?php
/**
 * Example function to hook into uo_forgot_after_success action.
 * This example demonstrates logging a success message when a user successfully requests a password reset.
 *
 * @param WP_User|WP_Error $user_or_error The user object if successful, or a WP_Error object if there was an issue.
 * @param string $email The email address used for the password reset request.
 */
function my_plugin_log_forgot_password_success( $user_or_error, $email ) {
    // Ensure the action was a success and we have a user object.
    if ( ! is_wp_error( $user_or_error ) && $user_or_error instanceof WP_User ) {
        // Log the event to the WordPress debug log.
        error_log( sprintf(
            'User "%s" (ID: %d) successfully requested a password reset for email: %s',
            $user_or_error->user_login,
            $user_or_error->ID,
            $email
        ) );

        // You could also trigger other actions here, like sending a custom notification email,
        // updating a user meta field, or redirecting the user to a specific page.
        // For example:
        // wp_redirect( home_url( '/password-reset-initiated-confirmation/' ) );
        // exit;
    }
}
add_action( 'uo_forgot_after_success', 'my_plugin_log_forgot_password_success', 10, 2 );

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/templates/frontend-login/modern_ui-lost-pwd.php:55
src/templates/frontend-login/layout_1-lost-pwd.php:48
src/classes/frontend-login-plus.php:3560

<div class="ult-notice ult-notice--success">
							<?php do_action( 'uo_forgot_before_success_message' ); ?>
							<?php echo $forgot_password_response->message; ?>
							<?php do_action( 'uo_forgot_after_success_message' ); ?>
						</div>
					</div>
					
					<?php do_action( 'uo_forgot_after_success' ); ?>
				
				<?php } else { ?>
					
					<?php do_action( 'uo_forgot_before_title' ); ?>

					<div class="ult-form__title">
						<?php echo $innerText['Password-Recovery-Title']; ?>


Scroll to Top