rest_prepare_user filter-hookWP 4.7.0

Filters user data returned from the REST API.

Usage

add_filter( 'rest_prepare_user', 'wp_kama_rest_prepare_user_filter', 10, 3 );

/**
 * Function for `rest_prepare_user` filter-hook.
 * 
 * @param WP_REST_Response $response The response object.
 * @param WP_User          $user     User object used to create response.
 * @param WP_REST_Request  $request  Request object.
 *
 * @return WP_REST_Response
 */
function wp_kama_rest_prepare_user_filter( $response, $user, $request ){

	// filter...
	return $response;
}
$response(WP_REST_Response)
The response object.
$user(WP_User)
User object used to create response.
$request(WP_REST_Request)
Request object.

Changelog

Since 4.7.0 Introduced.

Where the hook is called

WP_REST_Users_Controller::prepare_item_for_response()
rest_prepare_user
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php 1099
return apply_filters( 'rest_prepare_user', $response, $user, $request );

Where the hook is used in WordPress

Usage not found.