Wednesday 22 January 2014

Login With Username And Email Address

Have you ever tried of logging WordPress with email id, if not then follow this simple tutorial. Basically in WordPress, we have only option to login with username, when you add this snippet in functions.php we can also login with email address too.


function login_with_email$username) {
        $user = get_user_by('email',$username);
        if(!empty($user->user_login))
                $username = $user->user_login;
        return $username;
}
add_action('wp_authenticate','login_with_email');
function change_username($text){
       if(in_array($GLOBALS['pagenow'], array('wp-

login.php'))){
         if ($text == 'Username'){$text = 'Username / 

Email';}
            }
                return $text;
         }
add_filter( 'gettext', 'change_username' );

No comments:

Post a Comment