Action uncanny-learndash-toolkit

uo_reset_before_password

Fires before a user's password reset process begins, allowing for custom actions.

add_action( 'uo_reset_before_password', $callback, 10, 1 );

Description

Fires before the password input field in the reset password form. Developers can use this hook to add custom elements, validation, or modify the form structure before the user enters their new password.


Usage

add_action( 'uo_reset_before_password', 'your_function_name', 10, 1 );

Examples

<?php
/**
 * Example action hook for uo_reset_before_password.
 *
 * This function demonstrates how to use the 'uo_reset_before_password' action hook
 * to potentially add custom validation or modify the password reset form
 * before the password input fields are displayed.
 *
 * In this realistic example, we might want to check if the user is allowed
 * to reset their password based on some custom criteria or add a nonce field
 * for enhanced security. For simplicity, we'll just add a hidden field
 * to indicate that this reset is happening through a specific flow.
 */
add_action( 'uo_reset_before_password', 'my_custom_password_reset_logic', 10, 0 );

/**
 * Handles custom logic before the password reset fields are displayed.
 *
 * This function is hooked into 'uo_reset_before_password'. It assumes
 * no arguments are passed to the hook based on the provided source context
 * and internal usage.
 */
function my_custom_password_reset_logic() {
    // In a real-world scenario, you might have more complex logic here.
    // For example, checking user roles, specific user meta, or adding security nonces.

    // Example: Adding a custom hidden field to track the origin of the reset process.
    // This could be useful for analytics or specific handling on the server-side
    // during the actual password update process.
    ?>
    <input type="hidden" name="custom_reset_source" value="my_plugin_frontend_reset" />
    <?php

    // You could also add JavaScript to dynamically modify the form or provide user feedback.
    // For instance, you might want to enforce password strength policies here.
    ?>
    <script type="text/javascript">
        // Example: You could dynamically add a password strength indicator or
        // custom validation rules using JavaScript.
        // console.log('Custom logic executed before password fields.');
    </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:24
src/templates/frontend-login/modern_ui-reset-pwd.php:65
src/templates/frontend-login/layout_1-reset-pwd.php:58

<?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">
        <p>
            <label for="pass1"><?php echo $innerText['New-Password']; ?></label>
        </p>

        <div class="wp-pwd">
                            <span class="password-input-wrapper">


Scroll to Top