Description
The gravityflow_rest_api_capability_restart_workflow filter allows customization of the capabilities an authenticated request must have must have to access any of the following endpoints:
- Restart Workflow with Rest API V2
POST/wp-json/gf/v2/entries/[entry_id]/workflows/restart
Parameters
| Parameter | Type | Details |
|---|---|---|
| $capability | String | Required capability (or capabilities) checked via current_user_can to determine if the current user can restart the workflow 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 permissions check following this filter will return a WP_Error with:
| HTTP Status Code | Error Code | Error Message | Details |
|---|---|---|---|
| 401 (Unauthorized) | gravityflow_rest_cannot_get_steps | Sorry, you are not allowed to get steps for this form. | The user is not logged in. |
| 403 (Forbidden) | gravityflow_rest_cannot_get_steps | Sorry, you are not allowed to get steps for this form. | The user is logged in but doesn’t have permission. |
Examples
Check a different capability.
This example will lead to the request permissions check being performed against a different Gravity Flow capability
add_filter( 'gravityflow_rest_api_capability_restart_workflow', 'flow_capability_restart_workflow_type', 10, 2 );
function flow_capability_restart_workflow_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 plugin, a custom add-on, or with a code snippets plugin.
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-workflows.php file.