[wp-trac] [WordPress Trac] #9568: Allow users to log in using their email address

WordPress Trac noreply at wordpress.org
Thu Jan 22 15:41:51 UTC 2015


#9568: Allow users to log in using their email address
-------------------------------------------------+-------------------------
 Reporter:  Denis-de-Bernardy                    |       Owner:
     Type:  feature request                      |      Status:  assigned
 Priority:  normal                               |   Milestone:  4.2
Component:  Users                                |     Version:  2.8
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-testing needs-       |     Focuses:
  refresh needs-unit-tests                       |
-------------------------------------------------+-------------------------

Comment (by vhomenko):

 A snippet to reduce the noise level of the errors, in case of entering a
 wrong email address into the login form.

 {{{
 add_filter( 'wp_login_errors', 'consolidate_wrong_user_id_errors', 20 );

 function consolidate_wrong_user_id_errors( $errors ) {
         if ( ! is_wp_error( $errors ) ) return $errors;
         if ( 2 !== count( $errors->errors ) ) return $errors;

         $codes = $errors->get_error_codes();
         $is_invalid_username = in_array( 'invalid_username', $codes );
         $is_invalid_email = in_array( 'invalid_email', $codes );

         if ( $is_invalid_username && $is_invalid_email ) {
                 $errors->remove( 'invalid_username' );
         }

         return $errors;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/9568#comment:72>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list