rest_dispatch_request WordPress Filter Hook

The rest_dispatch_request hook is used to modify the parameters of a REST request prior to dispatching it. This hook allows you to change the endpoint, add query parameters, or even change the HTTP method of the request.

apply_filters( 'rest_dispatch_request', mixed $dispatch_result, WP_REST_Request $request, string $route, array $handler ) #

Filters the REST API dispatch request result.


Description

Allow plugins to override dispatching the request.


Top ↑

Parameters

$dispatch_result

(mixed)Dispatch result, will be used if not empty.

$request

(WP_REST_Request)Request used to generate the response.

$route

(string)Route matched for the request.

$handler

(array)Route handler used for the request.


Top ↑

Source

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

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
4.5.0Added $route and $handler parameters.
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.