GET/sites/$site/users
List the users of a site.
Resource Information
Method | GET |
---|---|
URL | https://public-api.wordpress.com/rest/v1.1/sites/$site/users |
Requires authentication? | Yes |
Method Parameters
Parameter | Type | Description |
---|---|---|
$site | (int|string) | Site ID or domain |
Query Parameters
Parameter | Type | Description |
---|---|---|
context | (string) |
|
http_envelope | (bool) |
|
pretty | (bool) |
|
meta | (string) | Optional. Loads data from the endpoints found in the 'meta' part of the response. Comma-separated list. Example: meta=site,likes |
fields | (string) | Optional. Returns specified fields only. Comma-separated list. Example: fields=ID,title |
callback | (string) | An optional JSONP callback function. |
number | (int) | Limit the total number of authors returned. Default: 20. |
offset | (int) | The first n authors to be skipped in the returned array. |
order | (string) |
|
order_by | (string) |
|
authors_only | (bool) | Set to true to fetch authors only |
include_viewers | (bool) | Set to true to include viewers for Simple sites. When you pass in this parameter, order, order_by and search_columns are ignored. Currently, `search` is limited to the first page of results. |
type | (string) |
Specify the post type to query authors for. Only works when combined with the `authors_only` flag. Defaults to 'post'. Post types besides post and page need to be whitelisted using the rest_api_allowed_post_types filter. |
search | (string) | Find matching users. |
search_columns | (array) | Specify which columns to check for matching users. Can be any of 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', and 'display_name'. Only works when combined with `search` parameter. |
role | (string) | Specify a specific user role to fetch. |
capability | (string) | Specify a specific capability to fetch. You can specify multiple by comma separating them, in which case the user needs to match all capabilities provided. |
Response Parameters
Parameter | Type | Description |
---|---|---|
found | (int) | The total number of authors found that match the request (ignoring limits and offsets). |
users | (array) | Array of user objects |
authors | (array) | Array of author objects. |
Resource Errors
This endpoint does not return any errors.
Example
curl \ -H 'authorization: Bearer YOUR_API_TOKEN' \ 'https://public-api.wordpress.com/rest/v1/sites/82974409/users'
<?php $options = array ( 'http' => array ( 'ignore_errors' => true, 'header' => array ( 0 => 'authorization: Bearer YOUR_API_TOKEN', ), ), ); $context = stream_context_create( $options ); $response = file_get_contents( 'https://public-api.wordpress.com/rest/v1/sites/82974409/users', false, $context ); $response = json_decode( $response ); ?>