On this page
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.
Parameters
$resultmixed-
Response to replace the requested version with. Can be anything a normal endpoint can return, or null to not hijack the request.
$serverWP_REST_Server-
Server instance.
$requestWP_REST_Request-
Request used to generate the response.
Source
File: wp-includes/rest-api/class-wp-rest-server.php. View all references
$result = apply_filters( 'rest_pre_dispatch', null, $this, $request );
Related
Used By
| Used By | Description |
|---|---|
| WP_REST_Server::serve_batch_request_v1() wp-includes/rest-api/class-wp-rest-server.php | Serves the batch/v1 request. |
| WP_REST_Server::dispatch() wp-includes/rest-api/class-wp-rest-server.php | Matches the request to a callback and call it. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/hooks/rest_pre_dispatch