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

Fires before errors are returned from a password reset request.


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


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


5.4.0Added the $user_data parameter.
4.4.0Added the $errors parameter.

User Contributed Notes

  1. Skip to note 2 content

    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.