Login and Registration: Pass $user_data parameter to the lostpassword_post action in retrieve_password().

Props wpgurudev, pagewidth, lukecavanagh, johnbillion, kkarpieszuk.
Fixes #38334.

git-svn-id: https://develop.svn.wordpress.org/trunk@46749 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-11-19 09:59:19 +00:00
parent 82e352e412
commit af941d438c

View File

@ -364,6 +364,7 @@ function wp_login_viewport_meta() {
*/ */
function retrieve_password() { function retrieve_password() {
$errors = new WP_Error(); $errors = new WP_Error();
$user_data = false;
if ( empty( $_POST['user_login'] ) || ! is_string( $_POST['user_login'] ) ) { if ( empty( $_POST['user_login'] ) || ! is_string( $_POST['user_login'] ) ) {
$errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or email address.' ) ); $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or email address.' ) );
@ -382,11 +383,13 @@ function retrieve_password() {
* *
* @since 2.1.0 * @since 2.1.0
* @since 4.4.0 Added the `$errors` parameter. * @since 4.4.0 Added the `$errors` parameter.
* @since 5.4.0 Added the `$user_data` parameter.
* *
* @param WP_Error $errors A WP_Error object containing any errors generated * @param WP_Error $errors A WP_Error object containing any errors generated
* by using invalid credentials. * by using invalid credentials.
* @param WP_User|false WP_User object if found, false if the user does not exist.
*/ */
do_action( 'lostpassword_post', $errors ); do_action( 'lostpassword_post', $errors, $user_data );
if ( $errors->has_errors() ) { if ( $errors->has_errors() ) {
return $errors; return $errors;