15

I have a very big multisite. And I got a request to enable option that multiple users can use the same email. I found a plugin "Allow Multiple Accounts" which doesn't work properly. I should figure out some other solution for that. I know that I could use something like adding +sometext to every email, so it will show different to Wordpress. Do you have some other solution, that can be done here?

4
  • 5
    You need to be careful with this. If you got this working and if you are trying to use the same email for multiple distinct individuals then any one of those individuals would be able to reset the password for any or all of the accounts that use the shared email. That email address is part of the security system.
    – s_ha_dum
    Dec 10, 2012 at 16:18
  • yes, I know that, but I am still searching for this solution
    – Bob
    Dec 10, 2012 at 19:19
  • 1
    Parham's anwer is prett neat, but I would also like to point out that the email addresses don't have to be real, so you can create accounts with fake email addresses. The user can go in and change it later if they would like to. This has advantages security-wise, and prevents problems with plugins and parts of WordPress core that assume there is one username per email address. Aug 31, 2017 at 22:12
  • Exactly what I needed Mr Me. I just want it for testing purposes. Sep 22, 2018 at 16:44

2 Answers 2

16

You can use wpmu_validate_user_signup filter to remove the error and then define WP_IMPORTING just to skip the email_exist() check in wp_insert_user() function:

add_filter('wpmu_validate_user_signup', 'skip_email_exist');
function skip_email_exist($result){
    if(isset($result['errors']->errors['user_email']) && ($key = array_search(__('Sorry, that email address is already used!'), $result['errors']->errors['user_email'])) !== false) {
        unset($result['errors']->errors['user_email'][$key]);
        if (empty($result['errors']->errors['user_email'])) unset($result['errors']->errors['user_email']);
    }
    define( 'WP_IMPORTING', 'SKIP_EMAIL_EXIST' );
    return $result;
}

UPDATE: for a non Multi-site setup try this code:

add_filter('pre_user_email', 'skip_email_exist');
function skip_email_exist($user_email){
    define( 'WP_IMPORTING', 'SKIP_EMAIL_EXIST' );
    return $user_email;
}
8
  • I think this is the right answer. Marked as correct. Thanks!
    – Bob
    Dec 11, 2012 at 13:23
  • 1
    This does not work in Wordpress 3.5.
    – Guillochon
    Jan 29, 2013 at 18:37
  • @Guillochon I don't see any change in WP 3.5 that would make this code to not work. And this is for a MULTI-SITE setup, are you testing on a WP MU setup?
    – Parham
    Jan 29, 2013 at 19:38
  • My mistake, I was trying for a single site setup. The "Multiple Accounts" plugin for single sites does not work anymore, so I was looking for alternatives.
    – Guillochon
    Jan 29, 2013 at 23:46
  • 1
    What happens with lost password notifications on multisite setups? How will this be handled? May 2, 2013 at 12:06
0

You can you use the Gmail alias feature:

and so on.

All emails will be delivered to the same address ([email protected]).

Inside Gmail, you can distinguish the emails using a filter or a search. For example, searching for to:[email protected] will show only the emails related to the first WordPress account.

This solution should not break the "Reset password" workflow in WordPress.

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