A client recently asked me how to change the default login function in WordPress so that users access the website with their email address, instead of a username.
In short, this can be done in three steps:
- Remove default authentication function
- Add custom authentication function
- Change text “Username” in wp-login.php to “Email”
Note: Don’t edit core files.
1. Remove WordPress default authentication function.
WordPress uses “authenticate” filter to perform additional validation at user login.
https://gist.github.com/bestwebsite/d09404c3a7dfd5fb7861
2. Add custom authentication function
https://gist.github.com/bestwebsite/e410de289a143a288f5a
3. Change text “Username” in wp-login.php to “Email”
We can use gettext filter to change text “Username” to “Email” without editing core files.
https://gist.github.com/bestwebsite/595229b67da218a8da3e