uo_forgot_before_error
Fires before an error is displayed during the password reset process.
add_action( 'uo_forgot_before_error', $callback, 10, 1 );
Description
Fires immediately before the error message is displayed on the forgot password form. This hook allows developers to add custom error handling, modify the error display, or perform other actions before the user sees any validation messages.
Usage
add_action( 'uo_forgot_before_error', 'your_function_name', 10, 1 );
Examples
// Example: Add a custom notification before the error message is displayed for the forgot password form.
add_action( 'uo_forgot_before_error', 'my_custom_forgot_password_error_notification', 10, 0 );
/**
* Displays a custom notification or logs an error before the default forgot password error message.
* This function is triggered by the 'uo_forgot_before_error' action hook.
*
* @since 1.0.0
*/
function my_custom_forgot_password_error_notification() {
// In a real-world scenario, you might want to check if there's a specific error
// or a user context to provide a more tailored message.
// For this example, we'll just add a generic informative message.
// You could potentially check global variables if the context is available,
// e.g., if a specific error code is set in $_GET or $_POST.
// Example:
// if ( isset( $_GET['error_code'] ) && $_GET['error_code'] === 'custom_user_error' ) {
// echo '<p class="ult-notice-text">A specific custom error occurred. Please try again.</p>';
// } else {
// // Default or other error handling
// // For this example, we'll just log a debug message.
// error_log( 'uo_forgot_before_error hook triggered. Potential issue with forgot password process.' );
// }
// For demonstration, let's simply output a simple message that will appear
// before the actual error message from the system.
// This might be used to provide additional instructions or context.
echo '<p class="ult-notice-text"><strong>Important:</strong> Please ensure you are using the email address registered with your account.</p>';
}
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:126
src/templates/frontend-login/layout_1-lost-pwd.php:119
$notice_css_classes[] = 'ult-form__validation--has-error';
} else {
$forgot_password_response = '';
}
?>
<?php do_action( 'uo_forgot_before_error' ); ?>
<div class="ult-form__validation <?php echo implode( ' ', $notice_css_classes ); ?>">
<div class="ult-notice ult-notice--error">
<?php do_action( 'uo_forgot_before_error_message' ); ?>
<span class="ult-notice-text"><?php echo isset( $forgot_password_response->message ) ? $forgot_password_response->message : ''; ?></span>