rest_pre_dispatch WordPress Filter Hook

The rest_pre_dispatch hook is triggered before a request is dispatched to a REST API endpoint. This hook can be used to modify the request before it is processed by the endpoint.

apply_filters( 'rest_pre_dispatch', mixed $result, WP_REST_Server $server, WP_REST_Request $request ) #

Filters the pre-calculated result of a REST API dispatch request.


Description

Allow hijacking the request before dispatching by returning a non-empty. The returned value will be used to serve the request instead.


Top ↑

Parameters

$result

(mixed)Response to replace the requested version with. Can be anything a normal endpoint can return, or null to not hijack the request.

$server

(WP_REST_Server)Server instance.

$request

(WP_REST_Request)Request used to generate the response.


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.