gravityflow_send_to_step_condition_not_met

Description

The gravityflow_send_to_step_condition_not_met filter determines what next step a workflow should proceed to instead of the selected step that failed its step conditions.

Note: This filter only executes if gravityflow_send_to_step_condition_met_required is also filtered to return true for the current potential step change.

Parameters

ParameterTypeDetails
$next_stepStepThe next step to send the entry to.
Defaults to the next step after the proposed new step that meets its’ start conditions.
$new_stepStepThe proposed new step that failed its step conditions.
$current_stepStepThe current step.

Examples

Identify a specific step to send to when condition is not met

add_filter( 'gravityflow_send_to_step_condition_not_met', 'jo_what_step_next', 10, 5 );
function jo_what_step_next( $next_step, $new_step, $current_step, $entry, $form ) {
    if ( $new_step->get_id() == '296' ) {
        $api = new Gravity_Flow_API( $form['id'] );
        $steps = $api->get_steps();

        foreach ( $steps as $potential_step ) {     
            if ( $potential_step->get_id() == '297' ) {
                error_log( 'Re-routing to 297' );
                $new_step = $potential_step;
                break;
            }
        }
    }
    return $next_step;
}

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?