uo_reset_after_error_message
Fires after an error message is displayed during the reset process.
add_action( 'uo_reset_after_error_message', $callback, 10, 1 );
Description
Fires after displaying the error message during the password reset process. Developers can hook into this action to perform custom actions or modifications after an error message has been shown to the user. This hook provides a late opportunity for integration.
Usage
add_action( 'uo_reset_after_error_message', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Adds a custom class to the error message paragraph when a password reset error occurs.
* This can be used for styling the error message differently, for example, by making it red.
*
* @param string $error The error message string.
*/
function my_custom_password_reset_error_styling( $error ) {
// Check if the error variable is not empty.
if ( ! empty( $error ) ) {
// Add a custom class to the paragraph containing the error message.
// We're assuming the error message is directly echoed by the hook's placement.
// In a real-world scenario, you might modify the output structure around the error.
// For this example, we'll just append a class to the potential surrounding <p> tag
// if the hook was designed to allow output modification. Since the hook is *after*
// the error, we'll demonstrate adding a class to a hypothetical parent element
// if it were possible to manipulate the HTML structure here.
// A more practical approach might involve adding CSS classes via JavaScript
// or a different hook if this hook only recieves the error string.
// Assuming the $error variable is accessible and we want to visually indicate an error.
// If this hook was designed to output something, we would echo it here.
// Since it's an action hook and placed *after* the error, we can't directly
// modify the HTML that contains the error in this context without more
// information about how the original template is structured.
// For demonstration purposes, let's assume we want to append a visual indicator
// if the error message itself contains specific keywords.
if ( strpos( $error, 'invalid' ) !== false || strpos( $error, 'expired' ) !== false ) {
echo '<span class="error-indicator">!</span>';
}
}
}
add_action( 'uo_reset_after_error_message', 'my_custom_password_reset_error_styling', 10, 1 );
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:18
src/templates/frontend-login/modern_ui-reset-pwd.php:121
src/templates/frontend-login/layout_1-reset-pwd.php:114
<?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 } ?>
<input type="hidden" id="user_login" name="rp_login" value="<?php echo esc_attr( $rp_login ); ?>"
autocomplete="off"/>
<?php do_action( 'uo_reset_before_password' ); ?>
<div class="user-pass1-wrap">