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

Fires before errors are returned from a password reset request.

Parameters

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

Source

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

Changelog

VersionDescription
5.4.0Added the $user_data parameter.
4.4.0Added the $errors parameter.
2.1.0Introduced.

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.