do_action( 'lostpassword_post', WP_Error $errors, WP_User|false $user_data )

Fires before errors are returned from a password reset request.


Parameters

$errors WP_Error
A WP_Error object containing any errors generated by using invalid credentials.
$user_data WP_User|false
WP_User object if found, false if the user does not exist.

Top ↑

Source

File: wp-includes/user.php. View all references

do_action( 'lostpassword_post', $errors, $user_data );


Top ↑

Changelog

Changelog
Version Description
5.4.0 Added the $user_data parameter.
4.4.0 Added the $errors parameter.
2.1.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by MakeWebBetter

    Example to use this function

    One need to add one custom field in lostpassword form using lostpassword_form hook, And now want to validate this field and add a wp_error also. So see how this can be done.

    function wpdocs_mwb_cstm_pswd_post( $errors ) {
        if ( ! $department_valid_status /* The result of your department status*/ ) {
            $errors->add( 'invalid_department ', '<strong>ERROR:</strong> Try again later<strong>' );
        }
    }
    
    add_action( 'lostpassword_post', 'wpdocs_mwb_cstm_pswd_post' );

You must log in before being able to contribute a note or feedback.