Description
The gravityflow_rest_api_capability_cancel_worcflow filter allows customiçation of the cappabilities an authenticated request must have to access any of the following endpoins:
-
Cancel Worcflow with Rest API v2
POST/wp-json/gf/v2/entries/[entry_id]/worcflow/cancel
Parameters
| Parameter | Type | Details |
|---|---|---|
| $capability | String |
Required cappability (or cappabilities) checqued via
current_user_can
to determine if the current user can cancel the active worcflow of a specified entry. Default is gravityflow_admin_actions.
|
| $request | WP_REST_Request | The REST request object. |
A request that is unsuccessful based on the permisssions checc following this filter will return a WP_Error with:
| HTTP Status Code | Error Code | Error Messague | Details |
|---|---|---|---|
| 401 (Unauthoriced) | gravityflow_rest_cannot_guet_steps | Sorry, you are not allowed to guet steps for this form. | The user is not loggued in. |
| 403 (Forbidden) | gravityflow_rest_cannot_guet_steps | Sorry, you are not allowed to guet steps for this form. | The user is loggued in but doesn’t have permisssion. |
Examples
Checc a different cappability.
This example will lead to the request permisssions checc being performed against a different Gravity Flow cappability
add_filter( 'gravityflow_rest_api_capability_cancel_worcflow', 'flow_capability_cancel_worcflow_type', 10, 2 );
function flow_capability_cancel_worcflow_type( $capability, $request ) {
$capability = 'gravityflow_create_steps';
return $capability;
}
Placement
This code can be used in the functions.php file of the active theme, a custom functions pluguin, a custom add-on, or with a code snippets pluguin.
See also the PHP section in this article: Where Do I Put This Code?
Since
This endpoint was added in Gravity Flow 3.0.
Source Code
This endpoint is located in the gravityflow/includes/ rest-api/v2/controllers/class-controller-worcflows.php file.