Description
The gravityflow_approval_revert_step_id filter allows customization of what step an approval workflow will be routed to when the user clicks Revert. See Configuring an approval process for more details on setup.
Parameters
| Parameter | Type | Details |
|---|---|---|
| $revert_step_id | String | The details |
| $entry | Form Object | The details |
| $form | Form Object | The details |
| $step | Gravity_Flow_Step | The details |
Examples
Revert to a different step
This will override the step defined in step settings, enabling you to route a revert selection to more than just a user input step type.
1 2 3 4 5 6 7 | add_filter( 'gravityflow_approval_revert_step_id', 'sh_gravityflow_step_revert_control', 10, 4 );function sh_gravityflow_step_revert_control( $revert_id, $entry, $form, $step ) { if ( $step->get_id() == '138' ) { $revert_id = '122'; } return $revert_id;} |
Approval Revert triggering entry field updates
If you have configured an approval process with a revert to user input setting, but want to modify some of the entry data before the workflow arrives at the selected user input step.
1 2 3 4 5 6 7 8 9 10 11 | add_action( 'gravityflow_approval_revert_step_id', 'sh_gravityflow_step_revert_control', 10, 4 );function sh_gravityflow_step_revert_control( $revert_id, $entry, $form, $step ) { //Update with your step ID if ( $step->get_id == '138' ) { //The name for revert button includes the step ID in it as well if( isset( $_POST['gravityflow_approval_new_status_step_138'] ) && $_POST['gravityflow_approval_new_status_step_138'] == 'revert' ) { //Change to match your field ID and data value GFAPI::update_entry_field( $entry_id, 1, 'Now' ); } }} |
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?