Make WordPress Core

Changeset 56937


Ignore:
Timestamp:
10/15/2023 02:02:34 PM (12 months ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/users.php

    r56600 r56937  
    257257            // Send the password reset link.
    258258            $user = get_userdata( $id );
    259             if ( retrieve_password( $user->user_login ) ) {
     259            if ( true === retrieve_password( $user->user_login ) ) {
    260260                ++$reset_count;
    261261            }
Note: See TracChangeset for help on using the changeset viewer.