1

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:

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.

4
  • 7
    And when someone wants to reset their password...?
    – webaware
    Dec 11, 2013 at 0:43
  • @webaware I have heard that email is sent to first user email, which is a sacrifice I am willing to make since it is assumed that it is the same user on all accounts....
    – Michael
    Dec 11, 2013 at 0:56
  • Maybe something like this? But you still have to take care of the password reset ... maybe only allow password recovery via username and not email?
    – birgire
    Dec 11, 2013 at 2:10
  • You probably need to have custom registration functionality to bypass this email check for existing user. Do you already have such code? Dec 11, 2013 at 9:08

2 Answers 2

4

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.

1

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

3
  • Changing core files is not recommended ...
    – birgire
    Dec 11, 2013 at 9:39
  • Agreed - but as this sounds like it could be a family website, I thought I'd give the OP an option.
    – TomC
    Dec 11, 2013 at 10:50
  • 4
    ps: we also have to keep in mind that your answer will probably be read by many other users looking for a solution to a similar problem and they might start editing core files to solve it ;-)
    – birgire
    Dec 11, 2013 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.