WordPress at a glance
filter is not described

rest_pre_serve_request filter-hook . WP 4.4.0

Filters whether the request has already been served.

Allow sending the request manually - by returning true, the API result will not be sent to the client.


add_filter( 'rest_pre_serve_request', 'filter_function_name_8384', 10, 4 );
function filter_function_name_8384( $served, $result, $request, $this ){
	// filter...

	return $served;
Whether the request has already been served.
Default: false
Result to send to the client. Usually a WP_REST_Response.
Request used to generate the response.
Server instance.


Since 4.4.0 Introduced.

Where the hook is called

wp-includes/rest-api/class-wp-rest-server.php 393
$served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );

Where in WP core the hook is used

wp-includes/default-filters.php 551
add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 );
wp-includes/rest-api.php 188
add_filter( 'rest_pre_serve_request', 'rest_send_cors_headers' );