Add user to site
const url = 'https://example.com/wp-json/wp2/site-manager/v1/sites/1/users';const options = { method: 'POST', headers: {'X-WP-Nonce': '<X-WP-Nonce>', 'Content-Type': 'application/json'}, body: '{"user_id":14,"role":"editor"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/wp-json/wp2/site-manager/v1/sites/1/users \ --header 'Content-Type: application/json' \ --header 'X-WP-Nonce: <X-WP-Nonce>' \ --data '{ "user_id": 14, "role": "editor" }'Adds an existing user to the blog (add_user_to_blog) with the role from the body.
`user_id` > 0 and a non-empty `role` are required, otherwise 400 `missing_fields`. Role must be one of core administrator/editor/author/contributor/subscriber — otherwise 400 `invalid_role`. Assigning administrator requires `manage_network_users` or `manage_network`, otherwise 403 `forbidden`. The global account is not created.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Site ID in the current network (WP_Site->blog_id).
Request Bodyrequired
Section titled “Request Bodyrequired”object
Existing WordPress user (get_user_by('id')). Required, > 0; otherwise 400 missing_fields. No such user — 404 user_not_found.
Role on this site for add_user_to_blog. Required. PHP accepts only administrator, editor, author, contributor, subscriber; anything else — 400 invalid_role. Assigning administrator requires manage_network_users or manage_network, otherwise 403 forbidden.
Example
{ "user_id": 14, "role": "editor"}Responses
Section titled “Responses”User added to the site.
object
Always true on HTTP 201.
Added user ID (as in the request body).
Role the user was added with.
Example
{ "added": true, "user_id": 14, "role": "editor"}Missing_fields — missing user_id or role; invalid_role — role not on the allow-list.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}Not authenticated. DualRest: rest_forbidden (status 401) when there is no cookie session. Cookie + X-WP-Nonce or Application Password.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}No permission on the blog, or administrator role without manage_network_users/manage_network (forbidden), or invalid REST nonce.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}User_not_found — no such WP user; site_not_in_network — site is not in the current network.
object
Machine-readable error or event code.
Message text (log, PIN, or password reset).
Extra WP_Error or license payload.
object
Examplegenerated
{ "code": "example", "message": "example", "data": {}}