Here’s a more technical and specific WordPress development question where a WordPress application has multiple emails stored for each login.
Question
I have a WordPress site that requires users to register using an email address as their username. It also grabs an additional email address during registration that becomes the user’s email meta data. This all works fine until someone loses their password and tries to reset it using the standard WordPress reset page. The problem is that WordPress is checking the username (an email address) against the email meta for the website users rather than against the username meta for users.
Any thoughts on how to approach this?
Answer
The retrieve_password() function WordPress uses to lookup a user is pluggable- which means you can copy it, alter it and WordPress will use your version instead of the core function.
Inside your custom function, using get_user_by( ‘login’, $email ); to retrieve a user by username… but providing the email instead should allow you to bypass the default behavior and lookup users correctly.