WordPress: Enable Email Address Login & Change Login Page Text


Drop this code snippet into your theme’s functions.php file to enable user login with email address, and also change login page text to inform about this functionality.

// login with email
add_action('wp_authenticate','email_login');
function email_login($user_name) {
	$user = get_user_by('email', $user_name);
	if(!empty($user->user_login))
		$user_name = $user->user_login;
	return $user_name;
}

// Change 'Username' to 'Username or Email Address' on login page
add_filter( 'gettext', 'login_text' );
add_filter( 'ngettext', 'login_text' );
function login_text( $translated ) {
     $translated = str_ireplace(  'Username',  'Username or Email Address',  $translated );
     return $translated;
}

Login code via Bavota