From 23ac8fbfe6a00ec3c6bc423ffbb8c0d4e2575f1d Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Sun, 15 Oct 2023 14:04:23 +0000 Subject: [PATCH] Users: Show "Password reset link sent" message only when finished. When an admin sends a password reset link to a user (from the Users UI screen), the "finished" UI message: >Password reset link sent. is displayed on "finished" and no longer displayed on error. **What is the change?** Previously, the conditional (for incrementing the reset counter) checked for a truthy return from `retrieve_password()`. But `retrieve_password()` always returns a truthy state: `true` (meaning "finished") or an instance of `WP_Error`. Thus, checking for a truthy meant the "finished" message was sent on both "finished" and error/failed. This fix checks for `retrieve_password()` returning `true` to indicate "finished". **What is displayed on error?** If `retrieve_password()` returns an instance of `WP_Error`, the following UI message is shown: >Password reset links sent to 0 users. The UI messages were not modified by this changeset. Follow-up to [50129]. Props letraceursnork, prashantbhivsane, audrasjb, costdev, dilipbheda, hareesh-pillai, hellofromTonya, ironprogrammer, huzaifaalmesbah, marybaum, nicolefurlan, oglekler, petitphp, SergeyBiryukov. Fixes #58407. Built from https://develop.svn.wordpress.org/trunk@56937 git-svn-id: http://core.svn.wordpress.org/trunk@56448 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/users.php | 2 +- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-admin/users.php b/wp-admin/users.php index bab7ad5196..94d891ae0c 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -256,7 +256,7 @@ switch ( $wp_list_table->current_action() ) { // Send the password reset link. $user = get_userdata( $id ); - if ( retrieve_password( $user->user_login ) ) { + if ( true === retrieve_password( $user->user_login ) ) { ++$reset_count; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index c15fa9b0ca..67a1a3d754 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-beta4-56936'; +$wp_version = '6.4-beta4-56937'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.