How to allow more than one registered user to have the same email?

How can I allow a user to register on the site and ignore the error WP throws back if email is already registered – “This email is already registered, please choose another one.”

I tried writing my own plugin but it isn’t working:

Read More
if($errors['field'.$field->id] == 'This email is already registered, please choose another one.')
unset($errors['field'.$field->id]);

Any help on this would be greatly appreciated.

PS.

i) I know its not ideal to allow same email for registration but can’t see another solution to allow same family members to register under different usernames but same family email.

ii) The answer on a previous question did not work on single site, using the code

add_filter('pre_user_email', 'skip_email_exist');

this is why I had to ask this question for single site solution.

Related posts

2 comments

  1. So unfortunately without major revisions to both code and database structure this is not possible because WordPress stores the user email in a “UNIQUE” row in the database. Just unsetting the error message will not solve this issue because the user does not get created.

  2. I’m assuming you’ve already looked at wp-includes/user.php, which I’m referring to below

    Simplest way: Comment out Line 1691 ( EDIT : THIS METHOD IS NOT RECOMMENDED AS IT'S EDITING CORE FILES AND ISN'T FUTURE-PROOF AND SHOULD BE CONSIDERED A LAST RESORT)

    Alternative way:
    Line 1690 users.php has the following:

    elseif ( email_exists( $user_email ) ) {
            $errors->add( 'email_exists', __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ) );
        }
    

    In your code example, you are using $errors['field'.$field->id]
    Have you checked to see if $errors['field'.$field->id] exists/is set?
    Not sure of correct syntax to use here, but you could check for, then unset something like $errors['email_exists']

    HTH

Comments are closed.