Restarting a Gravity Flow workflow after editing a field with GravityEdit

The code sample below targets specific forms by their IDs. Make sure to change those to the specific form ID connected to your View.

The code below restarts a Gravity Flow workflow after editing a field with GravityEdit (formerly known as Inline Edit).

add_filter( 'gravityview-inline-edit/entry-updated', 'gravityedit_trigger_workflow', 10, 5 );

function gravityedit_trigger_workflow( $update_result, $entry = array(), $form_id = 0, $gf_field = null, $original_entry = array() ) { 
	
	$run_on_forms = [10, 20, 30]; //The IDs of the Forms you'd like to affect

	if( ! in_array( $form_id, $run_on_forms ) ){
		return $update_result;
	}
        
        $run_on_fields = [1, 2, 3]; // If the edited field is not one of the specified fields, do not restart the workflow

        if ( ! in_array( $gf_field->id, $run_on_fields ) ) {
                return $update_result;
        }

	if( ! class_exists('Gravity_Flow_API') ) {
		return;
	}

	add_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 );
	$api = new Gravity_Flow_API( $form_id );
	$api->restart_workflow( $entry );
	remove_filter( 'gform_is_feed_asynchronous', '__return_false', 1294873 );
		
    return $update_result;
}

This code doesn't work when editing entries in GravityView's Edit Entry page. We have another code snippet for that.

If you are not sure how to add custom code to your theme, please take a look at this article

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us