I'am working on a new wordpress website, and I would like to create multiple users with the same exact email address. The purpose of this is to route several customer service accounts to a common email as means of consolidation.

I started by registering an email field in the rest api, as email field is not included in the default rest api settings.

Hence the following code was added in my functions.php file:

register_rest_field( 'user', 'user_email',
                            'get_callback'    => function ( $user ) {
                                return get_userdata($user['id'])->user_email;
                            'schema'          => null,

Then I issue 2 simple post requests using python to create 2 accounts with the same email,as follows:

import base64
import requests
import json


from Load_Credentials import user,password

credentials = user + ':' + password
token = base64.b64encode(credentials.encode())
header = {'Authorization': 'Basic ' + token.decode('utf-8'),'Content-Type': 'application/json','User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}

#first POST request with same email
x1={"username": "newuser1","email":"[email protected]","password":"check123"}

#second post request with same email
x2={"username": "newuser2","email":"[email protected]","password":"check123"}

This is the response I'am getting:

{'code': 'existing_user_email', 'message': 'Sorry, that email address is already used!', 'data': None}

Is there a way to allow creating 2 accounts with the same email ONLY when using the rest api. (normal registration procedure should continue to flag duplicate emails)

I appreciate your support on this matter.

1 Answer 1


I don't think it's possible. Using rest API or not do not change the fact WordPress is preventing it AT https://github.com/WordPress/wordpress-develop/blob/5.9/src/wp-includes/user.php#L2032

Your Answer

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

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