uo_reset_before_confirm_password
Fires before the password reset confirmation process begins, allowing for custom actions.
add_action( 'uo_reset_before_confirm_password', $callback, 10, 1 );
Description
Fires before the password confirmation field on the reset password form. Use this hook to add custom fields or modify the form's structure, for example, to collect additional user information or implement validation before the password is submitted.
Usage
add_action( 'uo_reset_before_confirm_password', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Example function to hook into 'uo_reset_before_confirm_password' action.
* This function might add a password strength meter validation or display a message
* before the confirm password field is shown.
*
* @param array $args An array of arguments passed to the hook. This might include user data, form elements, etc.
*/
function my_custom_reset_password_strength_check( $args = [] ) {
// In a real scenario, you might want to check if the user is logged in or if it's a reset context.
// For this example, we'll assume we're within a password reset flow.
// Let's add a simple JavaScript snippet to enhance password strength checking visually.
// In a real plugin, this would typically be enqueued properly, but for a direct hook example:
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
var passwordInput = $('#pass1'); // Assuming the password input has ID 'pass1'
var confirmPasswordInput = $('#pass2'); // Assuming the confirm password input has ID 'pass2'
var passwordStrengthMeter = $('#pass-strength-result'); // Assuming a div for strength display
if (passwordInput.length && confirmPasswordInput.length && passwordStrengthMeter.length) {
// Basic password strength indicator logic (can be much more complex)
passwordInput.on('input', function() {
var password = $(this).val();
var strength = '';
if (password.length < 6) {
strength = 'Weak';
passwordStrengthMeter.css('color', 'red');
} else if (password.length < 10) {
strength = 'Moderate';
passwordStrengthMeter.css('color', 'orange');
} else {
strength = 'Strong';
passwordStrengthMeter.css('color', 'green');
}
passwordStrengthMeter.text('Password Strength: ' + strength);
});
// Add a check to ensure passwords match when the form is submitted
// This is often handled server-side, but can be a client-side enhancement.
// For demonstration, let's just log a message.
// A full implementation would prevent form submission if passwords don't match.
confirmPasswordInput.on('input', function() {
if ($(this).val() !== passwordInput.val()) {
console.log('Passwords do not match!');
// In a real scenario, you'd display an error message to the user.
} else {
console.log('Passwords match!');
}
});
}
});
</script>
<?php
// You could also add some inline HTML, like a hint or a policy.
echo '<p class="password-reset-hint" style="font-size: 0.9em; color: #666;">Please ensure your password is at least 8 characters long and includes a mix of uppercase, lowercase, numbers, and symbols.</p>';
}
add_action( 'uo_reset_before_confirm_password', 'my_custom_reset_password_strength_check', 10, 0 ); // Priority 10, 0 accepted arguments
?>
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:42
src/templates/frontend-login/modern_ui-reset-pwd.php:84
src/templates/frontend-login/layout_1-reset-pwd.php:77
aria-describedby="pass-strength-result" required/>
</span>
</div>
<div class="wp-pwd">
<?php do_action( 'uo_reset_password_actions' ); ?>
</div>
</div>
<?php do_action( 'uo_reset_before_confirm_password' ); ?>
<p class="user-pass2-wrap">
<label for="pass2"><?php echo $innerText['Confirm-Password']; ?></label><br/>
<input type="password" name="pass2" id="pass2" class="input" size="20" value="" autocomplete="off" required/>
</p>
<div class="wp-pwd">
<?php do_action( 'uo_reset_confirm_password_actions' ); ?>
</div>