Filter uncanny-learndash-toolkit

uo_toolkit_reset_password_errors

Filters the response array after a password reset attempt to modify or add error messages.

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

Description

Filters the error message displayed when a user attempts to reset their password. Developers can use this hook to customize or translate the default error messages for invalid credentials or failed email sending during the password reset process.


Usage

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

Parameters

$forgot_password_response (mixed)
This parameter contains a mixed value, likely an object or array, that holds information about the response or errors related to a password reset attempt.

Return Value

The filtered value.


Examples

/**
 * Modify the reset password error message for invalid credentials.
 *
 * This filter allows developers to customize the error message displayed
 * when a user provides invalid credentials during the password reset process.
 *
 * @param string $message The original error message.
 * @return string The modified error message.
 */
add_filter( 'uo_toolkit_reset_password_errors', function( $message ) {
    // Example: Append a suggestion to check the email if it's the 'invalidcredentials' error
    if ( 'invalidcredentials' === $message ) {
        return $message . ' Please ensure you have entered the correct username or email address associated with your account.';
    }
    return $message; // Always return the modified or original message
}, 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/templates/login-page-ui-default.php:70

} elseif ( 'invalidcredentials' === $reset_password_sent_success ) {
					$forgot_password_response->message = $innerText['Failed-Pass-Creds'];
				} else {
					$forgot_password_response->message = $innerText['Failed-Send-Email'];
				}
			}

			$forgot_password_response->message = apply_filters( 'uo_toolkit_reset_password_errors', $forgot_password_response->message );

			include Config::get_template( apply_filters( 'uo-front-login-lost-pwd-template', 'frontend-login/' . $template_to_load . '-lost-pwd.php', $template_to_load ) );
		} elseif ( $register ) {
			//If registration is open and user is on register page!
			if ( $register_show ) {
				include Config::get_template( apply_filters( 'uo-front-login-register-template', 'frontend-login/' . $template_to_load . '-register.php', $template_to_load ) );
			}


Scroll to Top