Make WordPress Core

Ticket #22367: 22367.4.diff

File 22367.4.diff, 2.1 KB (added by donmhico, 5 years ago)

Refreshed the patch.

  • src/wp-admin/user-new.php

    diff --git src/wp-admin/user-new.php src/wp-admin/user-new.php
    index ef52612418..8daff39340 100644
    if ( isset( $_REQUEST['action'] ) && 'adduser' == $_REQUEST['action'] ) { 
    3434
    3535        $user_details = null;
    3636        $user_email   = wp_unslash( $_REQUEST['email'] );
    37         if ( false !== strpos( $user_email, '@' ) ) {
     37        if ( is_email( $user_email ) ) {
    3838                $user_details = get_user_by( 'email', $user_email );
    3939        } else {
    4040                if ( current_user_can( 'manage_network_users' ) ) {
  • src/wp-includes/class-wp-user-query.php

    diff --git src/wp-includes/class-wp-user-query.php src/wp-includes/class-wp-user-query.php
    index 33408e51d0..9cb4cd8c68 100644
    class WP_User_Query { 
    524524                        }
    525525                        if ( ! $search_columns ) {
    526526                                if ( false !== strpos( $search, '@' ) ) {
    527                                         $search_columns = array( 'user_email' );
     527                                        $search_columns = array( 'user_email', 'user_login' );
    528528                                } elseif ( is_numeric( $search ) ) {
    529529                                        $search_columns = array( 'user_login', 'ID' );
    530530                                } elseif ( preg_match( '|^https?://|', $search ) && ! ( is_multisite() && wp_is_large_network( 'users' ) ) ) {
  • src/wp-login.php

    diff --git src/wp-login.php src/wp-login.php
    index f7f0fa16ea..94620c764b 100644
    function retrieve_password() { 
    355355
    356356        if ( empty( $_POST['user_login'] ) || ! is_string( $_POST['user_login'] ) ) {
    357357                $errors->add( 'empty_username', __( '<strong>ERROR</strong>: Enter a username or email address.' ) );
    358         } elseif ( strpos( $_POST['user_login'], '@' ) ) {
    359                 $user_data = get_user_by( 'email', trim( wp_unslash( $_POST['user_login'] ) ) );
     358        } elseif ( is_email( $_POST['user_login'] ) ) {
     359                $user_login = trim( wp_unslash( $_POST['user_login'] ) );
     360
     361                $user_data = get_user_by( 'email', $user_login );
     362
     363                if ( empty( $user_data ) ) {
     364                        $user_data = get_user_by( 'email', $user_login );
     365                }
     366
    360367                if ( empty( $user_data ) ) {
    361368                        $errors->add( 'invalid_email', __( '<strong>ERROR</strong>: There is no account with that username or email address.' ) );
    362369                }