WordPress中文开发手册

  1. Home
  2. Docs
  3. WordPress中文开发手册
  4. WordPress REST API手册
  5. 资源
  6. 用户

用户

Schema #Schema

The schema defines all the fields that exist for a user object.

id
integer Unique identifier for the user.
Read only

Context: embed, view, edit

username
string Login name for the user.
Context: edit

name
string Display name for the user.
Context: embed, view, edit

first_name
string First name for the user.
Context: edit

last_name
string Last name for the user.
Context: edit

email
string, email The email address for the user.
Context: edit

url
string, uri URL of the user.
Context: embed, view, edit

description
string Description of the user.
Context: embed, view, edit

link
string, uri Author URL of the user.
Read only

Context: embed, view, edit

locale
string Locale for the user.
Context: edit

One of: , en_US

nickname
string The nickname for the user.
Context: edit

slug
string An alphanumeric identifier for the user.
Context: embed, view, edit

registered_date
string, datetime (ISO8601) Registration date for the user.
Read only

Context: edit

roles
array Roles assigned to the user.
Context: edit

password
string Password for the user (never included).
Context:

capabilities
object All capabilities assigned to the user.
Read only

Context: edit

extra_capabilities
object Any extra capabilities assigned to the user.
Read only

Context: edit

avatar_urls
object Avatar URLs for the user.
Read only

Context: embed, view, edit

meta
object Meta fields.
Context: view, edit

Example Request #Example Request

$ curl -X OPTIONS -i http://demo.wp-api.org/wp-json/wp/v2/users

Top ↑

List Users #List Users

Top ↑

Arguments #Arguments

context Scope under which the request is made; determines fields present in response.
Default: view

One of: view, embed, edit

page Current page of the collection.
Default: 1

per_page Maximum number of items to be returned in result set.
Default: 10

search Limit results to those matching a string.
exclude Ensure result set excludes specific IDs.
Default:

include Limit result set to specific IDs.
Default:

offset Offset the result set by a specific number of items.
order Order sort attribute ascending or descending.
Default: asc

One of: asc, desc

orderby Sort collection by object attribute.
Default: name

One of: id, include, name, registered_date, slug, email, url

slug Limit result set to users with a specific slug.
roles Limit result set to users matching at least one specific role provided. Accepts csv list or single role.
Top ↑

Definition #Definition

GET /wp/v2/users

Example Request #Example Request

$ curl http://demo.wp-api.org/wp-json/wp/v2/users

Top ↑

Retrieve a User #Retrieve a User

Top ↑

Arguments #Arguments

context Scope under which the request is made; determines fields present in response.
Default: view

One of: view, embed, edit

Top ↑

Definition #Definition

GET /wp/v2/users/

Example Request #Example Request

$ curl http://demo.wp-api.org/wp-json/wp/v2/users/

Top ↑

Create a User #Create a User

Top ↑

Arguments #Arguments

username Login name for the user.
Required: true

name Display name for the user.
first_name First name for the user.
last_name Last name for the user.
email The email address for the user.
Required: true

url URL of the user.
description Description of the user.
locale Locale for the user.
One of: , en_US

nickname The nickname for the user.
slug An alphanumeric identifier for the user.
roles Roles assigned to the user.
password Password for the user (never included).
Required: true

meta Meta fields.
Top ↑

Definition #Definition

POST /wp/v2/users

Top ↑

Update a User #Update a User

Top ↑

Arguments #Arguments

username Login name for the user.
name Display name for the user.
first_name First name for the user.
last_name Last name for the user.
email The email address for the user.
url URL of the user.
description Description of the user.
locale Locale for the user.
One of: , en_US

nickname The nickname for the user.
slug An alphanumeric identifier for the user.
roles Roles assigned to the user.
password Password for the user (never included).
meta Meta fields.
Top ↑

Definition #Definition

POST /wp/v2/users/

Example Request #Example Request

Top ↑

Delete a User #Delete a User

Top ↑

Arguments #Arguments

force Required to be true, as users do not support trashing.
reassign Reassign the deleted user’s posts and links to this user ID.
Top ↑

Definition #Definition

DELETE /wp/v2/users/

Example Request #Example Request

$ curl -X DELETE http://demo.wp-api.org/wp-json/wp/v2/users/