Skip to content

Commit

Permalink
Users: Show "Password reset link sent" message only when finished.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hellofromtonya committed Oct 15, 2023
1 parent 0633814 commit 39e2817
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/wp-admin/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@

// Send the password reset link.
$user = get_userdata( $id );
if ( retrieve_password( $user->user_login ) ) {
if ( true === retrieve_password( $user->user_login ) ) {
++$reset_count;
}
}
Expand Down

0 comments on commit 39e2817

Please sign in to comment.