From 39e28173d5c23787e7a9db2dbf60f2f249e13e44 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Sun, 15 Oct 2023 14:02:34 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@56937 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/users.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php index bab7ad5196..94d891ae0c 100644 --- a/src/wp-admin/users.php +++ b/src/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; } }