Tags

, , ,

Recently i needed to login in wordpress using email address in a project but in wordpress it’s disabled by default. If you wish to login using your email address just copy the codes and paste is in your theme functions.php this will allow you to login using your both username and email address.


function enable_email_address_login($username) {
$user = get_user_by('email', $username);
if(!empty($user->user_login))
$username = $user->user_login;
return $username;
}

add_action('wp_authenticate','enable_email_address_login');

Advertisements