gravityflow_approval_revert_step_id

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 Definition
$revert_step_id string The current entry array.
$entry Array The current entry array.
$form Array The form of current entry.
$step Gravity_Flow_Step The current step.

Examples

Example 1 - 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.

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;
}

Example 2 - 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.

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 should be placed in the functions.php file of your active theme or in a custom functions plugin.