PHP Class WP_REST_Users_Controller, wordpress

See also: WP_REST_Controller
Since: 4.7.0
Inheritance: extends WP_REST_Controller
显示文件 Open project: johnpbloch/wordpress Class Usage Examples

Protected Properties

Property Type Description
$meta WP_REST_User_Meta_Fields Instance of a user meta fields object.

Public Methods

Method Description
__construct ( ) Constructor.
check_user_password ( mixed $value, WP_REST_Request $request, string $param ) : WP_Error | string Check a user password for the REST API.
check_username ( mixed $value, WP_REST_Request $request, string $param ) : WP_Error | string Check a username for the REST API.
create_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Creates a single user.
create_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access create users.
delete_current_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Deletes the current user.
delete_current_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to delete the current user.
delete_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Deletes a single user.
delete_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access delete a user.
get_collection_params ( ) : array Retrieves the query params for collections.
get_current_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Retrieves the current user.
get_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Retrieves a single user.
get_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to read a user.
get_item_schema ( ) : array Retrieves the user's schema, conforming to JSON Schema.
get_items ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Retrieves all users.
get_items_permissions_check ( WP_REST_Request $request ) : true | WP_Error Permissions check for getting all users.
prepare_item_for_response ( WP_User $user, WP_REST_Request $request ) : WP_REST_Response Prepares a single user output for response.
register_routes ( ) Registers the routes for the objects of the controller.
update_current_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Updates the current user.
update_current_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to update the current user.
update_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Updates a single user.
update_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to update a user.

Protected Methods

Method Description
check_role_update ( integer $user_id, array $roles ) : true | WP_Error Determines if the current user is allowed to make the desired roles change.
prepare_item_for_database ( WP_REST_Request $request ) : object Prepares a single user for creation or update.
prepare_links ( WP_Post $user ) : array Prepares links for the user request.

Method Details

__construct() public method

Constructor.
Since: 4.7.0
public __construct ( )

check_role_update() protected method

Determines if the current user is allowed to make the desired roles change.
Since: 4.7.0
protected check_role_update ( integer $user_id, array $roles ) : true | WP_Error
$user_id integer User ID.
$roles array New user roles.
return true | WP_Error True if the current user is allowed to make the role change, otherwise a WP_Error object.

check_user_password() public method

Performs a couple of checks like edit_user() in wp-admin/includes/user.php.
Since: 4.7.0
public check_user_password ( mixed $value, WP_REST_Request $request, string $param ) : WP_Error | string
$value mixed The password submitted in the request.
$request WP_REST_Request Full details about the request.
$param string The parameter name.
return WP_Error | string The sanitized password, if valid, otherwise an error.

check_username() public method

Performs a couple of checks like edit_user() in wp-admin/includes/user.php.
Since: 4.7.0
public check_username ( mixed $value, WP_REST_Request $request, string $param ) : WP_Error | string
$value mixed The username submitted in the request.
$request WP_REST_Request Full details about the request.
$param string The parameter name.
return WP_Error | string The sanitized username, if valid, otherwise an error.

create_item() public method

Creates a single user.
Since: 4.7.0
public create_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

create_item_permissions_check() public method

Checks if a given request has access create users.
Since: 4.7.0
public create_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
return true | WP_Error True if the request has access to create items, WP_Error object otherwise.

delete_current_item() public method

Deletes the current user.
Since: 4.7.0
public delete_current_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

delete_current_item_permissions_check() public method

Checks if a given request has access to delete the current user.
Since: 4.7.0
public delete_current_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
return true | WP_Error True if the request has access to delete the item, WP_Error object otherwise.

delete_item() public method

Deletes a single user.
Since: 4.7.0
public delete_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

delete_item_permissions_check() public method

Checks if a given request has access delete a user.
Since: 4.7.0
public delete_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
return true | WP_Error True if the request has access to delete the item, WP_Error object otherwise.

get_collection_params() public method

Retrieves the query params for collections.
Since: 4.7.0
public get_collection_params ( ) : array
return array Collection parameters.

get_current_item() public method

Retrieves the current user.
Since: 4.7.0
public get_current_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

get_item() public method

Retrieves a single user.
Since: 4.7.0
public get_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

get_item_permissions_check() public method

Checks if a given request has access to read a user.
Since: 4.7.0
public get_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
return true | WP_Error True if the request has read access for the item, otherwise WP_Error object.

get_item_schema() public method

Retrieves the user's schema, conforming to JSON Schema.
Since: 4.7.0
public get_item_schema ( ) : array
return array Item schema data.

get_items() public method

Retrieves all users.
Since: 4.7.0
public get_items ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

get_items_permissions_check() public method

Permissions check for getting all users.
Since: 4.7.0
public get_items_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
return true | WP_Error True if the request has read access, otherwise WP_Error object.

prepare_item_for_database() protected method

Prepares a single user for creation or update.
Since: 4.7.0
protected prepare_item_for_database ( WP_REST_Request $request ) : object
$request WP_REST_Request Request object.
return object $prepared_user User object.

prepare_item_for_response() public method

Prepares a single user output for response.
Since: 4.7.0
public prepare_item_for_response ( WP_User $user, WP_REST_Request $request ) : WP_REST_Response
$user WP_User User object.
$request WP_REST_Request Request object.
return WP_REST_Response Response object.

register_routes() public method

Registers the routes for the objects of the controller.
See also: register_rest_route()
Since: 4.7.0
public register_routes ( )

update_current_item() public method

Updates the current user.
Since: 4.7.0
public update_current_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

update_current_item_permissions_check() public method

Checks if a given request has access to update the current user.
Since: 4.7.0
public update_current_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
return true | WP_Error True if the request has access to update the item, WP_Error object otherwise.

update_item() public method

Updates a single user.
Since: 4.7.0
public update_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

update_item_permissions_check() public method

Checks if a given request has access to update a user.
Since: 4.7.0
public update_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
return true | WP_Error True if the request has access to update the item, WP_Error object otherwise.

Property Details

$meta protected_oe property

Instance of a user meta fields object.
Since: 4.7.0
protected WP_REST_User_Meta_Fields $meta
return WP_REST_User_Meta_Fields