Log in to WordPress using an Email Address
by Bandicoot Marketing on | Posted in Tutorials | 26 comments
I needed to figure out how to allow a user to use either their username or email address to log into WordPress. It took a bit of rooting around but the final piece of code ended up being pretty simple.
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');
Place that in your functions.php
file and you will be able to sign into your WordPress site using an email address or by default, the username.
26 comments for “Log in to WordPress using an Email Address”