Make WordPress Core

Ticket #58527: 58527.patch

File 58527.patch, 1.8 KB (added by hiren1094, 2 years ago)

Patch Added

  • src/wp-admin/users.php

    diff --git a/src/wp-admin/users.php b/src/wp-admin/users.php
    index 2c635c543a..bcde4c6735 100644
    a b switch ( $wp_list_table->current_action() ) { 
    255255                        }
    256256
    257257                        // Send the password reset link.
    258                         $user = get_userdata( $id );
    259                         if ( retrieve_password( $user->user_login ) ) {
     258                        $user                      = get_userdata( $id );
     259                        $retrieve_password = retrieve_password( $user->user_login );
     260                        if ( is_wp_error( $retrieve_password ) ) {
     261                                $redirect = add_query_arg(
     262                                        array(
     263                                                'reset_count' => $reset_count,
     264                                                'update'      => 'resetpassword',
     265                                                'error'       => 1,
     266                                        ),
     267                                        $redirect
     268                                );
     269                                wp_redirect( $redirect );
     270                                exit;
     271                        } else {
    260272                                ++$reset_count;
    261273                        }
    262274                }
    switch ( $wp_list_table->current_action() ) { 
    633645                                        $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . $message . '</p></div>';
    634646                                        break;
    635647                                case 'resetpassword':
    636                                         $reset_count = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0;
    637                                         if ( 1 === $reset_count ) {
     648                                        $reset_count      = isset( $_GET['reset_count'] ) ? (int) $_GET['reset_count'] : 0;
     649                                        $reset_pass_error = isset( $_GET['error'] ) ? (int) $_GET['error'] : 0;
     650                                        if ( 0 === $reset_count && 1 === $reset_pass_error ) {
     651                                                $message = sprintf(
     652                                                        /* translators: %s: Documentation URL. */
     653                                                        __( '<strong>Error:</strong> The email could not be sent. Your site may not be correctly configured to send emails. <a href="%s">Get support for resetting your password</a>.' ),
     654                                                        esc_url( __( 'https://wordpress.org/documentation/article/reset-your-password/' ) )
     655                                                );
     656                                        } elseif ( 1 === $reset_count ) {
    638657                                                $message = __( 'Password reset link sent.' );
    639658                                        } else {
    640659                                                /* translators: %s: Number of users. */