Skip to content

Add user to site

POST
/wp-json/wp2/site-manager/v1/sites/{blog_id}/users
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.
blog_id
required
integer

Site ID in the current network (WP_Site->blog_id).

Media typeapplication/json
object
user_id
required

Existing WordPress user (get_user_by('id')). Required, > 0; otherwise 400 missing_fields. No such user — 404 user_not_found.

integer
role
required

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.

string
Example
{
"user_id": 14,
"role": "editor"
}

User added to the site.

Media typeapplication/json
object
added

Always true on HTTP 201.

boolean
user_id

Added user ID (as in the request body).

integer
role

Role the user was added with.

string
Example
{
"added": true,
"user_id": 14,
"role": "editor"
}

Missing_fields — missing user_id or role; invalid_role — role not on the allow-list.

Media typeapplication/json
object
code

Machine-readable error or event code.

string
message

Message text (log, PIN, or password reset).

string
data

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.

Media typeapplication/json
object
code

Machine-readable error or event code.

string
message

Message text (log, PIN, or password reset).

string
data

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.

Media typeapplication/json
object
code

Machine-readable error or event code.

string
message

Message text (log, PIN, or password reset).

string
data

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.

Media typeapplication/json
object
code

Machine-readable error or event code.

string
message

Message text (log, PIN, or password reset).

string
data

Extra WP_Error or license payload.

object
Examplegenerated
{
"code": "example",
"message": "example",
"data": {}
}