uo_reset_before_error
Fires before the user reset process encounters an error, allowing for custom error handling or logging.
add_action( 'uo_reset_before_error', $callback, 10, 1 );
Description
Fires immediately before displaying an error message during the password reset process. Developers can use this hook to perform actions, such as logging the error, or modifying the error display logic before it's rendered to the user.
Usage
add_action( 'uo_reset_before_error', 'your_function_name', 10, 1 );
Examples
// Example: Add a class to the error message container if a specific condition is met.
add_action( 'uo_reset_before_error', function() {
// Assuming $error is a global variable or passed in a way that's accessible here.
// In a real scenario, you might need to check if the error is of a specific type
// or contains certain keywords to apply conditional styling.
global $error; // Accessing the global error variable
if ( ! empty( $error ) && strpos( $error, 'invalid' ) !== false ) {
echo '<div class="uo-reset-error-wrapper uo-reset-invalid-error">';
} else {
echo '<div class="uo-reset-error-wrapper">';
}
}, 10, 0 ); // Priority 10, 0 accepted arguments
// Example: Prepend an icon before the error message.
add_action( 'uo_reset_before_error_message', function() {
// This hook is specifically designed to add content before the error message itself.
// We'll add a Font Awesome warning icon.
echo '<i class="fas fa-exclamation-triangle" aria-hidden="true"></i> ';
}, 10, 0 );
// Example: Append a timestamp to the error message for debugging purposes.
add_action( 'uo_reset_after_error_message', function() {
// This hook is placed after the error message.
// We'll add a timestamp for logging or debugging.
echo ' (Logged at: ' . current_time( 'mysql' ) . ')';
}, 10, 0 );
// Example: Close the error message container div.
// This hook needs to be placed *after* the error message has been displayed.
// If your template structure looks like the provided example,
// you'll likely need a `uo_reset_after_error` hook to close the div.
// For this example, let's assume such a hook exists and add logic to it.
// If `uo_reset_after_error` is not a defined hook, this specific example would need
// to be adapted or placed within a `uo_reset_before_form` if you can ensure
// the `if (!empty($error))` block is closed correctly.
// Given the provided structure, a `uo_reset_after_error` hook would be the ideal place.
// For demonstration, let's simulate its existence.
/*
add_action( 'uo_reset_after_error', function() {
echo '</div>'; // Close the div opened in uo_reset_before_error
}, 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/templates/frontend-login/default-reset-pwd.php:14
src/templates/frontend-login/modern_ui-reset-pwd.php:113
src/templates/frontend-login/layout_1-reset-pwd.php:106
<?php do_action( 'uo_reset_before_title' ); ?>
<h2><?php echo $innerText['Reset-Password-Title']; ?></h2>
<?php do_action( 'uo_reset_before_description' ); ?>
<p><?php echo $innerText['Reset-Password-Desc']; ?></p>
<?php do_action( 'uo_reset_before_form' ); ?>
<form name="resetpassform" id="resetpassform" action="?action=validatepasswordreset" method="post" autocomplete="off">
<?php if ( ! empty( $error ) ) { ?>
<?php do_action( 'uo_reset_before_error' ); ?>
<p>
<?php do_action( 'uo_reset_before_error_message' ); ?>
<?php echo $error; ?>
<?php do_action( 'uo_reset_after_error_message' ); ?>
</p>
<?php } ?>