We don’t know about you, but we have literally thousands of logins to manage and it’s hard enough to remember your password–much less your username. Here’s an easy way to let your WordPress users login using their email address and password so they don’t have to remember their username.
All you have to do is locate your functions.php
file (located in your theme’s directory). So that’s something like wp-content/themes/yourtheme/functions.php
. Then, add the following line of code to that file. We like to add it towards the bottom of the file.
// login with email 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');
Save and upload your functions.php
file and you’re all done.
Users can now login to WordPress using any login form (the wp-login.php
form or something like Login With Ajax) using their email and their password (no username).
They can still use their username and password–if they really want to.