Login with Username or Email Address to WordPress

Add Tool

Login with Username or Email Address to WordPress


Login with Username or Email Address to WordPress

Simply add this WordPress snippet to the functions.php of your WordPress theme. This code will let users login using an email address or a username. The second snippet will change the text on the login page from “username” to “username / email” but feel free to change the login text to anything you would like.

You can see:  How to Customize login form WordPress?

<?php
function login_with_email_address($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_address');
function change_username_wps_text($text){
       if(in_array($GLOBALS['pagenow'], array('wp-login.php'))){
         if ($text == 'Username'){$text = 'Username / Email';}
            }
                return $text;
         }
add_filter( 'gettext', 'change_username_wps_text' );
?>

Congratulation Now your WordPress login form not only support username but also support Email Address.

Source


Tags: wordpress login, wordpress, wordpress blog login, wordpress admin login, wordpress login page, wp login, wordpress login url, wordpress login link, wordpress themes
Payza

About Masum Billah

Login with Username or Email Address to WordPress 1stWebSuite website seo tool is a free website ranking tool site provides a lot of on page and off page seo useful tools for you. On this site, we have a large number of website ranking tools


SIGN UP TO GET UPDATE TO YOUR INBOX




Discuss about: Login with Username or Email Address to WordPress


adf.ly