1

While looking at the source code of a popular membership plugin, I found out that they allow changing of email ID without 'verifying' it. In fact, even WP core allows two different users to have same email ID. I'm not sure if it's by design.

The problem, I have is that when two users have the same email ID, my get_user_by( 'email', 'xyz@pqr.com' ); function breaks. What WP does is simply look into the table and return the first user it finds in the table that has matching email ID.

Now, if I've just the email ID of the user and I want to log-them in programmatically, I'll have to write a custom function to check for all users in DB that share the email ID.

Has anyone else faced problem with email authentication? If yes, how do you uniquely identify a user with email?

  • I can't confirm your issue - when I try to register as a new user on my site, with an existing email address, I get the message:* 'ERROR: This email is already registered, please choose another one.'* (no membership plugins active) what is the 'popular membership plugin' you have tried? – Michael Apr 6 '17 at 17:17
  • @Michael - the problem is not at the time of registration; and has got nothing to do with the plugin. I found the bug while studying the code of the plugin. Here's what you do: - 1. Create two users 2. Verify a common email ID for both the users. 3. Now try to authenticate the second user with email. – TheBigK Apr 7 '17 at 1:57
  • step 2 does not work in my site - when I try to add a new user with an existing email address, via the dashboard, the moment II click 'add new user' button, I already get the message that the email address exists... – Michael Apr 7 '17 at 2:17
  • This is strange. Maybe just create two users with different email IDs first and then change one of the user's email ID. I can do this on my latest WordPress install. All wordpress cares about is whether you verify the email ID that you've entered. No duplicate email. PS: Do this from admin cp. – TheBigK Apr 7 '17 at 4:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.