rest_prepare_user
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
rest_prepare_user
wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php 1099
return apply_filters( 'rest_prepare_user', $response, $user, $request );