These routes allow you to retrieve/create/update/delete various user data in WP.
Since WP version 5.6, routes have been added that allow you to retrieve/create/update/delete application passwords for a specific user.
Possible routes (endpoints are described below):
/wp/v2/users // works with all users
/wp/v2/users/{ID} // works with the specified user
/wp/v2/users/me // works with the current user
Schema
The schema shows all fields that exist for the object: the fields of the object that the request will return.
Parameter
Context
Description
id Number readonly
embed, view, edit
Unique identifier for the user.
username String required
edit
Login name for the user.
name String
embed, view, edit
Display name of the user.
first_name String
edit
User's first name.
last_name String
edit
User's last name.
email String required
edit
User's email address.
url String
embed, view, edit
User's URL.
description String
embed, view, edit
User's description.
link String readonly
embed, view, edit
Author URL for the user.
locale String
edit
Locale for the user.
nickname String
edit
User's nickname.
slug String
embed, view, edit
Alphanumeric identifier for the user.
registered_date String readonly
edit
User's registration date.
roles Array
edit
Roles assigned to the user.
password String required
User's password (never displayed).
capabilities Object readonly
edit
All capabilities assigned to the user.
extra_capabilities Object readonly
edit
Any additional capabilities assigned to the user.
avatar_urls Object readonly
embed, view, edit
User's avatar URLs.
meta Object
view, edit
Meta fields.
wp/v2/users
An OPTIONS request to the route will return a complete description of this route: endpoints, their parameters, schema.
$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/users
GitHub
{
"namespace": "wp/v2",
"methods": [
"GET",
"POST"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"description": "Рамки в которых сделан запрос, определяют поля в ответе.",
"type": "string",
"enum": [
"view",
"embed",
"edit"
],
"default": "view",
"required": false
},
"page": {
"description": "Текущая страница коллекции.",
"type": "integer",
"default": 1,
"minimum": 1,
"required": false
},
"per_page": {
"description": "Максимальное число объектов возвращаемое в выборке.",
"type": "integer",
"default": 10,
"minimum": 1,
"maximum": 100,
"required": false
},
"search": {
"description": "Ограничить результаты до совпадающих со строкой.",
"type": "string",
"required": false
},
"exclude": {
"description": "Убедиться что выборка исключает определенные ID.",
"type": "array",
"items": {
"type": "integer"
},
"default": [],
"required": false
},
"include": {
"description": "Ограничить выборку до определенных ID.",
"type": "array",
"items": {
"type": "integer"
},
"default": [],
"required": false
},
"offset": {
"description": "Сдвиг выборки на определенное число объектов.",
"type": "integer",
"required": false
},
"order": {
"default": "asc",
"description": "Упорядочить сортировку атрибута по возрастанию или убыванию.",
"enum": [
"asc",
"desc"
],
"type": "string",
"required": false
},
"orderby": {
"default": "name",
"description": "Сортировать коллекцию по атрибуту объекта.",
"enum": [
"id",
"include",
"name",
"registered_date",
"slug",
"include_slugs",
"email",
"url"
],
"type": "string",
"required": false
},
"slug": {
"description": "Ограничить выборку пользователями с одним или более специальными ярлыками.",
"type": "array",
"items": {
"type": "string"
},
"required": false
},
"roles": {
"description": "Ограничить выборку до пользователей удовлетворяющих как минимум одной указанной роли. Можно указать CSV список или одну роль.",
"type": "array",
"items": {
"type": "string"
},
"required": false
},
"who": {
"description": "Ограничить выборку пользователями-авторами.",
"type": "string",
"enum": [
"authors"
],
"required": false
}
}
},
{
"methods": [
"POST"
],
"args": {
"username": {
"description": "Имя входа для пользователя.",
"type": "string",
"required": true
},
"name": {
"description": "Отображаемое имя пользователя.",
"type": "string",
"required": false
},
"first_name": {
"description": "Имя пользователя.",
"type": "string",
"required": false
},
"last_name": {
"description": "Фамилия пользователя.",
"type": "string",
"required": false
},
"email": {
"description": "Адрес email пользователя.",
"type": "string",
"format": "email",
"required": true
},
"url": {
"description": "URL пользователя.",
"type": "string",
"format": "uri",
"required": false
},
"description": {
"description": "Описание пользователя.",
"type": "string",
"required": false
},
"locale": {
"description": "Локаль для пользователя.",
"type": "string",
"enum": [
"",
"en_US",
"ru_RU"
],
"required": false
},
"nickname": {
"description": "Ник пользователя.",
"type": "string",
"required": false
},
"slug": {
"description": "Буквенно-цифровой идентификатор пользователя.",
"type": "string",
"required": false
},
"roles": {
"description": "Роли назначенные пользователю.",
"type": "array",
"items": {
"type": "string"
},
"required": false
},
"password": {
"description": "Пароль пользователя (никогда не показывается).",
"type": "string",
"required": true
},
"meta": {
"description": "Мета поля.",
"type": "object",
"properties": [],
"required": false
}
}
}
],
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "user",
"type": "object",
"properties": {
"id": {
"description": "Уникальный идентификатор пользователя.",
"type": "integer",
"context": [
"embed",
"view",
"edit"
],
"readonly": true
},
"username": {
"description": "Имя входа для пользователя.",
"type": "string",
"context": [
"edit"
],
"required": true
},
"name": {
"description": "Отображаемое имя пользователя.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"first_name": {
"description": "Имя пользователя.",
"type": "string",
"context": [
"edit"
]
},
"last_name": {
"description": "Фамилия пользователя.",
"type": "string",
"context": [
"edit"
]
},
"email": {
"description": "Адрес email пользователя.",
"type": "string",
"format": "email",
"context": [
"edit"
],
"required": true
},
"url": {
"description": "URL пользователя.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"description": {
"description": "Описание пользователя.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"link": {
"description": "URL автора для пользователя.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
],
"readonly": true
},
"locale": {
"description": "Локаль для пользователя.",
"type": "string",
"enum": [
"",
"en_US",
"ru_RU"
],
"context": [
"edit"
]
},
"nickname": {
"description": "Ник пользователя.",
"type": "string",
"context": [
"edit"
]
},
"slug": {
"description": "Буквенно-цифровой идентификатор пользователя.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"registered_date": {
"description": "Дата регистрации пользователя.",
"type": "string",
"format": "date-time",
"context": [
"edit"
],
"readonly": true
},
"roles": {
"description": "Роли назначенные пользователю.",
"type": "array",
"items": {
"type": "string"
},
"context": [
"edit"
]
},
"password": {
"description": "Пароль пользователя (никогда не показывается).",
"type": "string",
"context": [],
"required": true
},
"capabilities": {
"description": "Все возможности назначенные пользователю.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"extra_capabilities": {
"description": "Любые дополнительные возможности назначенные пользователю.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"avatar_urls": {
"description": "URL аватара пользователя.",
"type": "object",
"context": [
"embed",
"view",
"edit"
],
"readonly": true,
"properties": {
"24": {
"description": "URL аватары с размером изображения в 24 пикселей.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"48": {
"description": "URL аватары с размером изображения в 48 пикселей.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"96": {
"description": "URL аватары с размером изображения в 96 пикселей.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
}
}
},
"meta": {
"description": "Мета поля.",
"type": "object",
"context": [
"view",
"edit"
],
"properties": []
}
}
},
"_links": {
"self": [
{
"href": "https://wp-kama.ru/api/wp/v2/users"
}
]
}
}
List of users
The algorithm is similar to the function get_users() .
Request type
Access: public
GET /wp/v2/users
Request parameters
context(string)
The frames within which the request is made define the fields in the response.
Can be: view, embed, edit .
Default: view
page(integer)
The current page of the collection.
Default: 1
per_page(integer)
The maximum number of objects returned in the selection.
Default: 10
search(string)
Limit results to those matching the string.
exclude(array)
Exclude certain IDs from the selection. An array of IDs is specified.
Default: []
include(array)
Limit the selection to certain IDs. An array of IDs is specified.
Default: []
offset(integer)
Offset the selection by a certain number of objects.
order(string)
Sort in ascending (asc) or descending (desc) order.
Can be: asc, desc
Default: asc
orderby(string)
The field by which to sort the collection.
Can be: id, include, name, registered_date, slug, include_slugs, email, url .
Default: name
slug(array)
The slug of the user to retrieve. Multiple slugs can be specified in an array.
roles(array)
Get users with a specified role. Multiple roles can be specified in an array. A CSV list or a single role can be specified.
who(string)
Limit the selection to author users.
Can be: authors .
Example request
$ curl http://demo.wp-api.org/wp-json/wp/v2/users?search=human
Response:
[
{
"id": 1,
"name": "Human Made",
"url": "",
"description": "",
"link": "https://demo.wp-api.org/author/humanmade/",
"slug": "humanmade",
"avatar_urls": {
"24": "http://2.gravatar.com/avatar/83888eb8aea456e4322577f96b4dbaab?s=24&d=mm&r=g",
"48": "http://2.gravatar.com/avatar/83888eb8aea456e4322577f96b4dbaab?s=48&d=mm&r=g",
"96": "http://2.gravatar.com/avatar/83888eb8aea456e4322577f96b4dbaab?s=96&d=mm&r=g"
},
"meta": [],
"_links": {
"self": [
{
"href": "https://demo.wp-api.org/wp-json/wp/v2/users/1"
}
],
"collection": [
{
"href": "https://demo.wp-api.org/wp-json/wp/v2/users"
}
]
}
},
{ ... }
]
Creating a user
The algorithm is similar to the function wp_create_user() .
Request type
Access: authorization required
POST /wp/v2/users
Request parameters
username(string) (required)
Login name for the user.
email(string) (required)
User's email address.
password(string) (required)
User's password (never displayed).
name(string)
Display name of the user.
first_name(string)
User's first name.
last_name(string)
User's last name.
url(string)
User's URL.
description(string)
User's description.
locale(string)
Locale for the user. Can be: '', en_US, ru_RU, uk .
nickname(string)
User's nickname.
slug(string)
Alphanumeric identifier for the user.
roles(array)
Roles assigned to the user. An array of roles is specified.
meta(object)
Meta fields.
Example request
$ curl -X POST -i http://example.com/wp-json/wp/v2/[email protected] &password=123456
Response:
{
"id": 2,
"username": "neuser",
"name": "neuser",
"first_name": "",
"last_name": "",
"email": "[email protected] ",
"url": "",
"description": "",
"link": "http://example.com/author/neuser/",
"locale": "ru_RU",
"nickname": "neuser",
"slug": "neuser",
"roles": [
"subscriber"
],
"registered_date": "2018-08-31T13:36:18+00:00",
"capabilities": {
"read": true,
"level_0": true,
"subscriber": true
},
"extra_capabilities": {
"subscriber": true
},
"avatar_urls": {
"24": "http://0.gravatar.com/avatar/3731f606afa8dccc9123bdd4062c4af1?s=24&d=mm&r=g",
"48": "http://0.gravatar.com/avatar/3731f606afa8dccc9123bdd4062c4af1?s=48&d=mm&r=g",
"96": "http://0.gravatar.com/avatar/3731f606afa8dccc9123bdd4062c4af1?s=96&d=mm&r=g"
},
"meta": [],
"_links": {
"self": [
{
"href": "http://example.com/wp-json/wp/v2/users/2"
}
],
"collection": [
{
"href": "http://example.com/wp-json/wp/v2/users"
}
]
}
}
Example request in PHP with authorization
Authorization works based on Application Passwords
$res = wp_remote_post( 'https://wp-kama.dev/api/wp/v2/users', [
'headers' => [
'Authorization' => 'Basic a21RyBYVjJzIE5a2RVBWjQFtYTpg5W5uSTIYTRVIFUgeaw==',
],
'body' => [
'username' => 'testets2',
'email' => '[email protected] ',
'password' => 'test123',
],
] );
if( 200 === wp_remote_retrieve_response_code( $res ) ){
// success
}
else {
// error
}
// out
print_r( json_decode( wp_remote_retrieve_body( $res ) ) );
As a result, we will get:
// Possible errors on successful request:
stdClass Object(
[code] => existing_user_login
[message] => Sorry, this username already exists!
[data] =>
)
stdClass Object(
[code] => existing_user_email
[message] => Sorry, this email address is already in use!
[data] =>
)
// user created
stdClass Object(
[id] => 4562
[username] => testets2
[name] => testets2
[first_name] =>
[last_name] =>
[email] => [email protected]
[url] =>
[description] =>
[link] => https://wp-kama.dev/id_author/testets2
[locale] => ru_RU
[nickname] =>
[slug] => testets2
[roles] => Array(
[0] => subscriber
)
[registered_date] => 2021-07-25T14:04:18+00:00
[capabilities] => stdClass Object(
[read] => 1
[level_0] => 1
[subscriber] => 1
)
[extra_capabilities] => stdClass Object(
[subscriber] => 1
)
[avatar_urls] => stdClass Object(
[24] => https://secure.gravatar.com/avatar/2c0ba19f07a7894f544290488963e835?s=24&d=mystery&r=g
[48] => https://secure.gravatar.com/avatar/2c0ba19f07a7894f544290488963e835?s=48&d=mystery&r=g
[96] => https://secure.gravatar.com/avatar/2c0ba19f07a7894f544290488963e835?s=96&d=mystery&r=g
)
[meta] => Array()
[_links] => stdClass Object(
[self] => Array(
[0] => stdClass Object(
[href] => https://wp-kama.dev/api/wp/v2/users/4562
)
)
[collection] => Array(
[0] => stdClass Object(
[href] => https://wp-kama.dev/api/wp/v2/users
)
)
)
)
wp/v2/users/{ID}
An OPTIONS request to the route will return a complete description of this route: endpoints, their parameters, schema.
$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/users/{ID}
GitHub
{
"namespace": "wp/v2",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"id": {
"required": false,
"description": "Уникальный идентификатор пользователя.",
"type": "integer"
},
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"embed",
"edit"
],
"description": "Рамки в которых сделан запрос, определяют поля в ответе.",
"type": "string"
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"id": {
"required": false,
"description": "Уникальный идентификатор пользователя.",
"type": "integer"
},
"username": {
"required": false,
"description": "Имя входа для пользователя.",
"type": "string"
},
"name": {
"required": false,
"description": "Отображаемое имя пользователя.",
"type": "string"
},
"first_name": {
"required": false,
"description": "Имя пользователя.",
"type": "string"
},
"last_name": {
"required": false,
"description": "Фамилия пользователя.",
"type": "string"
},
"email": {
"required": false,
"description": "Адрес e-mail пользователя.",
"type": "string"
},
"url": {
"required": false,
"description": "URL пользователя.",
"type": "string"
},
"description": {
"required": false,
"description": "Описание пользователя.",
"type": "string"
},
"locale": {
"required": false,
"enum": [
"",
"en_US",
"ru_RU",
"uk"
],
"description": "Локаль для пользователя.",
"type": "string"
},
"nickname": {
"required": false,
"description": "Ник пользователя.",
"type": "string"
},
"slug": {
"required": false,
"description": "Буквенно-цифровой идентификатор пользователя.",
"type": "string"
},
"roles": {
"required": false,
"description": "Роли назначенные пользователю.",
"type": "array",
"items": {
"type": "string"
}
},
"password": {
"required": false,
"description": "Пароль пользователя (никогда не показывается).",
"type": "string"
},
"meta": {
"required": false,
"description": "Мета поля.",
"type": "object"
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"id": {
"required": false,
"description": "Уникальный идентификатор пользователя.",
"type": "integer"
},
"force": {
"required": false,
"default": false,
"description": "Должно быть истинным, так как пользователей нельзя переместить в корзину.",
"type": "boolean"
},
"reassign": {
"required": true,
"description": "Переназначить удаленные записи пользователя и ссылки на этот ID пользователя.",
"type": "integer"
}
}
}
],
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "user",
"type": "object",
"properties": {
"id": {
"description": "Уникальный идентификатор пользователя.",
"type": "integer",
"context": [
"embed",
"view",
"edit"
],
"readonly": true
},
"username": {
"description": "Имя входа для пользователя.",
"type": "string",
"context": [
"edit"
],
"required": true
},
"name": {
"description": "Отображаемое имя пользователя.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"first_name": {
"description": "Имя пользователя.",
"type": "string",
"context": [
"edit"
]
},
"last_name": {
"description": "Фамилия пользователя.",
"type": "string",
"context": [
"edit"
]
},
"email": {
"description": "Адрес e-mail пользователя.",
"type": "string",
"format": "email",
"context": [
"edit"
],
"required": true
},
"url": {
"description": "URL пользователя.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"description": {
"description": "Описание пользователя.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"link": {
"description": "URL автора для пользователя.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
],
"readonly": true
},
"locale": {
"description": "Локаль для пользователя.",
"type": "string",
"enum": [
"",
"en_US",
"ru_RU",
"uk"
],
"context": [
"edit"
]
},
"nickname": {
"description": "Ник пользователя.",
"type": "string",
"context": [
"edit"
]
},
"slug": {
"description": "Буквенно-цифровой идентификатор пользователя.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"registered_date": {
"description": "Дата регистрации пользователя.",
"type": "string",
"format": "date-time",
"context": [
"edit"
],
"readonly": true
},
"roles": {
"description": "Роли назначенные пользователю.",
"type": "array",
"items": {
"type": "string"
},
"context": [
"edit"
]
},
"password": {
"description": "Пароль пользователя (никогда не показывается).",
"type": "string",
"context": [],
"required": true
},
"capabilities": {
"description": "Все возможности назначенные пользователю.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"extra_capabilities": {
"description": "Любые дополнительные возможности назначенные пользователю.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"avatar_urls": {
"description": "URL аватара пользователя.",
"type": "object",
"context": [
"embed",
"view",
"edit"
],
"readonly": true,
"properties": {
"24": {
"description": "URL аватары с размером изображения в 24 пикселей.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"48": {
"description": "URL аватары с размером изображения в 48 пикселей.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"96": {
"description": "URL аватары с размером изображения в 96 пикселей.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
}
}
},
"meta": {
"description": "Мета поля.",
"type": "object",
"context": [
"view",
"edit"
],
"properties": []
}
}
}
}
Retrieving a user
The algorithm is similar to the function get_userdata() .
Request type
Access: public
GET /wp/v2/users/{id}
Request parameters
context(string)
The scope in which the request is made; defines the fields present in the response.
Can be: view, embed, edit
Default: view
Example request
$ curl http://demo.wp-api.org/wp-json/wp/v2/users/1
{
"id": 1,
"name": "Human Made",
"url": "",
"description": "",
"link": "https://demo.wp-api.org/author/humanmade/",
"slug": "humanmade",
"avatar_urls": {
"24": "http://2.gravatar.com/avatar/83888eb8aea456e4322577f96b4dbaab?s=24&d=mm&r=g",
"48": "http://2.gravatar.com/avatar/83888eb8aea456e4322577f96b4dbaab?s=48&d=mm&r=g",
"96": "http://2.gravatar.com/avatar/83888eb8aea456e4322577f96b4dbaab?s=96&d=mm&r=g"
},
"meta": [],
"_links": {
"self": [
{
"href": "https://demo.wp-api.org/wp-json/wp/v2/users/1"
}
],
"collection": [
{
"href": "https://demo.wp-api.org/wp-json/wp/v2/users"
}
]
}
}
Updating a user
The algorithm is similar to the function wp_update_user() .
Request type
Access: authorization required
POST|PUT|PATCH /wp/v2/users/{id}
Request parameters
username(string)
Login name for the user.
name(string)
Display name of the user.
first_name(string)
User's first name.
last_name(string)
User's last name.
email(string)
User's email address.
url(string)
User's URL to the posts page.
description(string)
User's description.
locale(string)
Locale for the user. Can be: '', en_US, ru_RU, uk .
nickname(string)
User's nickname.
slug(string)
User's slug.
roles(array)
Roles assigned to the user. An array of strings.
password(string)
User's password (never displayed).
meta(object)
Meta fields.
Example request
$ curl -X POST http://demo.wp-api.org/wp-json/wp/v2/users/[email protected]
Deleting a user
The algorithm is similar to the function wp_delete_user() .
Request type
Access: authorization required
DELETE /wp/v2/users/{id}
Request parameters
force(true/false)
Should always be true, as users cannot be moved to the trash.
Default: false
reassign(number) (required)
ID of the user to whom all posts and links of the deleted user should be reassigned. If this parameter is not specified, all posts of the deleted user will also be deleted.
Example request
$ curl -X DELETE http://demo.wp-api.org/wp-json/wp/v2/users/2
Error: the reassign parameter is not specified
{
"code": "rest_missing_callback_param",
"message": "Missing parameter: reassign",
"data": {
"status": 400,
"params": [
"reassign"
]
}
}
Let's specify this parameter:
$ curl -X DELETE http://demo.wp-api.org/wp-json/wp/v2/users/2?reassign=1
Again an error: force=true must be specified
{
"code": "rest_trash_not_supported",
"message": "Users cannot be moved to the trash. Set 'force=true' for deletion.",
"data": {
"status": 501
}
}
Let's specify this parameter as well
$ curl -X DELETE http://demo.wp-api.org/wp-json/wp/v2/users/2?reassign=1&force=true
User deleted:
{
"deleted": true,
"previous": {
"id": 2,
"username": "neuser",
"name": "neuser",
"first_name": "",
"last_name": "",
"email": "[email protected] ",
"url": "",
"description": "",
"link": "http://example.com/author/neuser/",
"locale": "ru_RU",
"nickname": "neuser",
"slug": "neuser",
"roles": [
"subscriber"
],
"registered_date": "2018-08-31T13:36:18+00:00",
"capabilities": {
"read": true,
"level_0": true,
"subscriber": true
},
"extra_capabilities": {
"subscriber": true
},
"avatar_urls": {
"24": "http://0.gravatar.com/avatar/3731f606afa8dccc9123bdd4062c4af1?s=24&d=mm&r=g",
"48": "http://0.gravatar.com/avatar/3731f606afa8dccc9123bdd4062c4af1?s=48&d=mm&r=g",
"96": "http://0.gravatar.com/avatar/3731f606afa8dccc9123bdd4062c4af1?s=96&d=mm&r=g"
},
"meta": []
}
}
wp/v2/users/me
The route requires authorization in the REST.
An OPTIONS request to the route will return a complete description of this route: endpoints, their parameters, schema.
$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/users/me
GitHub
{
"namespace": "wp/v2",
"methods": [
"GET",
"POST",
"PUT",
"PATCH",
"DELETE"
],
"endpoints": [
{
"methods": [
"GET"
],
"args": {
"context": {
"required": false,
"default": "view",
"enum": [
"view",
"embed",
"edit"
],
"description": "Scope under which the request is made; determines fields present in response.",
"type": "string"
}
}
},
{
"methods": [
"POST",
"PUT",
"PATCH"
],
"args": {
"username": {
"required": false,
"description": "Login name for the user.",
"type": "string"
},
"name": {
"required": false,
"description": "Display name for the user.",
"type": "string"
},
"first_name": {
"required": false,
"description": "First name for the user.",
"type": "string"
},
"last_name": {
"required": false,
"description": "Last name for the user.",
"type": "string"
},
"email": {
"required": false,
"description": "The email address for the user.",
"type": "string"
},
"url": {
"required": false,
"description": "URL of the user.",
"type": "string"
},
"description": {
"required": false,
"description": "Description of the user.",
"type": "string"
},
"locale": {
"required": false,
"enum": [
"",
"en_US"
],
"description": "Locale for the user.",
"type": "string"
},
"nickname": {
"required": false,
"description": "The nickname for the user.",
"type": "string"
},
"slug": {
"required": false,
"description": "An alphanumeric identifier for the user.",
"type": "string"
},
"roles": {
"required": false,
"description": "Roles assigned to the user.",
"type": "array",
"items": {
"type": "string"
}
},
"password": {
"required": false,
"description": "Password for the user (never included).",
"type": "string"
},
"meta": {
"required": false,
"description": "Meta fields.",
"type": "object"
}
}
},
{
"methods": [
"DELETE"
],
"args": {
"force": {
"required": false,
"default": false,
"description": "Required to be true, as users do not support trashing.",
"type": "boolean"
},
"reassign": {
"required": true,
"description": "Reassign the deleted user's posts and links to this user ID.",
"type": "integer"
}
}
}
],
"schema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "user",
"type": "object",
"properties": {
"id": {
"description": "Unique identifier for the user.",
"type": "integer",
"context": [
"embed",
"view",
"edit"
],
"readonly": true
},
"username": {
"description": "Login name for the user.",
"type": "string",
"context": [
"edit"
],
"required": true
},
"name": {
"description": "Display name for the user.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"first_name": {
"description": "First name for the user.",
"type": "string",
"context": [
"edit"
]
},
"last_name": {
"description": "Last name for the user.",
"type": "string",
"context": [
"edit"
]
},
"email": {
"description": "The email address for the user.",
"type": "string",
"format": "email",
"context": [
"edit"
],
"required": true
},
"url": {
"description": "URL of the user.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"description": {
"description": "Description of the user.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"link": {
"description": "Author URL of the user.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
],
"readonly": true
},
"locale": {
"description": "Locale for the user.",
"type": "string",
"enum": [
"",
"en_US"
],
"context": [
"edit"
]
},
"nickname": {
"description": "The nickname for the user.",
"type": "string",
"context": [
"edit"
]
},
"slug": {
"description": "An alphanumeric identifier for the user.",
"type": "string",
"context": [
"embed",
"view",
"edit"
]
},
"registered_date": {
"description": "Registration date for the user.",
"type": "string",
"format": "date-time",
"context": [
"edit"
],
"readonly": true
},
"roles": {
"description": "Roles assigned to the user.",
"type": "array",
"items": {
"type": "string"
},
"context": [
"edit"
]
},
"password": {
"description": "Password for the user (never included).",
"type": "string",
"context": [],
"required": true
},
"capabilities": {
"description": "All capabilities assigned to the user.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"extra_capabilities": {
"description": "Any extra capabilities assigned to the user.",
"type": "object",
"context": [
"edit"
],
"readonly": true
},
"avatar_urls": {
"description": "Avatar URLs for the user.",
"type": "object",
"context": [
"embed",
"view",
"edit"
],
"readonly": true,
"properties": {
"24": {
"description": "Avatar URL with image size of 24 pixels.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"48": {
"description": "Avatar URL with image size of 48 pixels.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
},
"96": {
"description": "Avatar URL with image size of 96 pixels.",
"type": "string",
"format": "uri",
"context": [
"embed",
"view",
"edit"
]
}
}
},
"meta": {
"description": "Meta fields.",
"type": "object",
"context": [
"view",
"edit"
],
"properties": []
}
}
},
"_links": {
"self": "https://demo.wp-api.org/wp-json/wp/v2/users/me"
}
}
Retrieving the current user
The route works similarly to the previous wp/v2/users/{ID}
.
$ curl http://example.com/wp-json/wp/v2/users/me
{
"id": 1,
"name": "kama",
"url": "",
"description": "",
"link": "http://example.com/author/kama/",
"slug": "kama",
"avatar_urls": {
"24": "http://1.gravatar.com/avatar/155e695ab2251ee3c482c1e3e690683b?s=24&d=mm&r=g",
"48": "http://1.gravatar.com/avatar/155e695ab2251ee3c482c1e3e690683b?s=48&d=mm&r=g",
"96": "http://1.gravatar.com/avatar/155e695ab2251ee3c482c1e3e690683b?s=96&d=mm&r=g"
},
"meta": [],
"_links": {
"self": [
{
"href": "http://example.com/wp-json/wp/v2/users/1"
}
],
"collection": [
{
"href": "http://example.com/wp-json/wp/v2/users"
}
]
}
}
Updating the current user
See the route wp/v2/users/{ID}
.
Deleting the current user
See the route wp/v2/users/{ID}
.