DescriptionDescription
This filter is run in permission callback of REST API routes of the plugin after remote authentication, which sets the current user.
It allows to enable or disable REST API routes of the plugin and to check for user capability for example.
By default, REST API routes of the plugin are disabled.
ArgumentsArguments
Argument | Type | Description |
$proceed | boolean | Whether to proceed the request |
$request | WP_REST_Request | Generated request object |
ExampleExample
PHP
functions.php
function prefix_rest_permission( $proceed, $request ) {
if ( '/wpgb/v1/fetch' === $request->get_route() ) {
$proceed = current_user_can( 'manage_options' );
}
return $proceed;
}
add_filter( 'wp_grid_builder/rest_api/permission', 'prefix_rest_permission', 10, 2 );