Make WordPress Core


Ignore:
Timestamp:
02/22/2016 11:14:27 PM (8 years ago)
Author:
ocean90
Message:

Authentication: Allow users to log in using their email address.

Introduces wp_authenticate_email_password() which is hooked into authenticate after wp_authenticate_username_password().

Props Denis-de-Bernardy, ericlewis, vhomenko, MikeHansenMe, swissspidy, ocean90.
Fixes #9568.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-login.php

    r36487 r36617  
    530530<form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url( network_site_url( 'wp-login.php?action=lostpassword', 'login_post' ) ); ?>" method="post">
    531531    <p>
    532         <label for="user_login" ><?php _e('Username or Email:') ?><br />
     532        <label for="user_login" ><?php _e('Username or Email') ?><br />
    533533        <input type="text" name="user_login" id="user_login" class="input" value="<?php echo esc_attr($user_login); ?>" size="20" /></label>
    534534    </p>
     
    757757    if ( !empty($_POST['log']) && !force_ssl_admin() ) {
    758758        $user_name = sanitize_user($_POST['log']);
    759         if ( $user = get_user_by('login', $user_name) ) {
     759        $user = get_user_by( 'login', $user_name );
     760
     761        if ( ! $user && strpos( $user_name, '@' ) ) {
     762            $user = get_user_by( 'email', $user_name );
     763        }
     764
     765        if ( $user ) {
    760766            if ( get_user_option('use_ssl', $user->ID) ) {
    761767                $secure_cookie = true;
     
    883889<form name="loginform" id="loginform" action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>" method="post">
    884890    <p>
    885         <label for="user_login"><?php _e('Username') ?><br />
     891        <label for="user_login"><?php _e('Username or Email') ?><br />
    886892        <input type="text" name="log" id="user_login"<?php echo $aria_describedby_error; ?> class="input" value="<?php echo esc_attr( $user_login ); ?>" size="20" /></label>
    887893    </p>
Note: See TracChangeset for help on using the changeset viewer.