rest_pre_serve_request WordPress Filter Hook

The rest_pre_serve_request hook allows you to modify the data that is returned by the REST API before it is served to the client. This can be useful for adding extra data to the response or for filtering the data that is returned.

apply_filters( 'rest_pre_serve_request', bool $served, WP_HTTP_Response $result, WP_REST_Request $request, WP_REST_Server $server ) #

Filters whether the REST API request has already been served.


Description

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


Top ↑

Parameters

$served

(bool)Whether the request has already been served. Default false.

$result

(WP_HTTP_Response)Result to send to the client. Usually a WP_REST_Response.

$request

(WP_REST_Request)Request used to generate the response.

$server

(WP_REST_Server)Server instance.


Top ↑

Source

File: wp-includes/rest-api/class-wp-rest-server.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.