gravityflow_approval_revert_step_id

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

ParameterTypeDetails
$revert_step_idStringThe details
$entryForm ObjectThe details
$formForm ObjectThe details
$stepGravity_Flow_StepThe 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?