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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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;
}
Method 2
You can you use the Gmail alias feature:
- First WordPress account: [email protected]
- Second WordPress account: [email protected]
- Third WordPress account: [email protected]
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.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0