WordPress at Your Fingertips
filter is not described

rest_pre_serve_request filter-hook . WP 4.4.0

Filters whether the REST API 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_7658', 10, 4 );
function filter_function_name_7658( $served, $result, $request, $server ){
	// 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 465
$served = apply_filters( 'rest_pre_serve_request', false, $result, $request, $this );

Where in WP core the hook is used WordPress

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