WordPress.org

Make WordPress Core

Ticket #22367: wordpress-trunk-fix-login.patch

File wordpress-trunk-fix-login.patch, 972 bytes (added by gravitylover, 5 years ago)

Allow users to reset password who have emails as usernames

  • wp-login.php

     
    282282
    283283        if ( empty( $_POST['user_login'] ) ) {
    284284                $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or email address.'));
    285         } elseif ( strpos( $_POST['user_login'], '@' ) ) {
     285        } elseif ( is_email( $_POST['user_login'] ) ) {
    286286                $user_data = get_user_by( 'email', trim( $_POST['user_login'] ) );
    287287                if ( empty( $user_data ) )
    288                         $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.'));
     288                  $user_data = get_user_by( 'login', trim( $_POST['user_login'] ) );
     289                if ( empty( $user_data ) )
     290                        $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that username or email address.'));
    289291        } else {
    290292                $login = trim($_POST['user_login']);
    291293                $user_data = get_user_by('login', $login);