rest_dispatch_request filter-hookWP 4.4.0

Filters the REST API dispatch request result.

Allow plugins to override dispatching the request.

Usage

add_filter( 'rest_dispatch_request', 'wp_kama_rest_dispatch_request_filter', 10, 4 );

/**
 * Function for `rest_dispatch_request` filter-hook.
 * 
 * @param mixed           $dispatch_result Dispatch result, will be used if not empty.
 * @param WP_REST_Request $request         Request used to generate the response.
 * @param string          $route           Route matched for the request.
 * @param array           $handler         Route handler used for the request.
 *
 * @return mixed
 */
function wp_kama_rest_dispatch_request_filter( $dispatch_result, $request, $route, $handler ){

	// filter...
	return $dispatch_result;
}
$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.

Changelog

Since 4.4.0 Introduced.
Since 4.5.0 Added $route and $handler parameters.

Where the hook is called

WP_REST_Server::respond_to_request()
rest_dispatch_request
wp-includes/rest-api/class-wp-rest-server.php 1137
$dispatch_result = apply_filters( 'rest_dispatch_request', null, $request, $route, $handler );

Where the hook is used in WordPress

Usage not found.