uo_reset_before_submit
Fires before the user reset password form is submitted, allowing for pre-submission modifications or validation.
add_action( 'uo_reset_before_submit', $callback, 10, 1 );
Description
Fires before the password reset form is submitted. This hook allows developers to add custom actions or modify form elements just before the user confirms their new password, offering a final opportunity for validation or enhancement before submission.
Usage
add_action( 'uo_reset_before_submit', 'your_function_name', 10, 1 );
Examples
// Example: Add an extra confirmation step before the password reset form is submitted.
add_action( 'uo_reset_before_submit', 'my_uo_add_password_reset_confirmation', 10 );
/**
* Adds a JavaScript confirmation dialog before the password reset form is submitted.
*
* @param array $args An array of arguments passed to the hook. (Not used in this example but good practice to include)
*/
function my_uo_add_password_reset_confirmation( $args = array() ) {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Find the form associated with the password reset.
// This assumes the form has a specific ID or class, adjust if necessary.
var resetForm = $('#reset-password-form'); // Replace with your actual form ID or selector
if (resetForm.length) {
resetForm.on('submit', function(e) {
var confirmReset = confirm('<?php esc_html_e( 'Are you sure you want to reset your password?', 'your-text-domain' ); ?>');
if (!confirmReset) {
e.preventDefault(); // Prevent form submission if the user cancels
}
});
}
});
</script>
<?php
}
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:54
src/templates/frontend-login/modern_ui-reset-pwd.php:125
src/templates/frontend-login/layout_1-reset-pwd.php:118
<div class="wp-pwd">
<?php do_action( 'uo_reset_confirm_password_actions' ); ?>
</div>
<?php do_action( 'uo_reset_before_captcha' ); ?>
<!-- <p class="description indicator-hint">--><?php /*echo $innerText['Password-Indicator-Hint'];*/ ?><!--</p>-->
<br class="clear"/>
<input type="hidden" name="rp_key" value="<?php echo esc_attr( $rp_key ); ?>"/>
<?php do_action( 'uo_reset_before_submit' ); ?>
<p class="submit"><input type="submit" name="wp-submit" id="wp-submit"
class="button button-primary button-large"
value="<?php echo $innerText['Reset-Password-Button']; ?>"/></p>
<?php do_action( 'uo_reset_after_submit' ); ?>
</form>
<?php do_action( 'uo_reset_after_form' ); ?>
<?php do_action( 'uo_reset_after_container' ); ?>