Using Gravity Forms ‘gform_zapier_feed_conditional_logic’ PHP filter

The gform_zapier_feed_conditional_logic filter allows you to override the feed conditional logic rule during form submission, enabling the definition of multiple rules.

Usage

add_filter('gform_zapier_feed_conditional_logic', 'your_function_name', 10, 3);

Parameters

  • $logic (string) – The existing logic array.
  • $form (Form Object) – The form object.
  • $zap (object) – The Zapier feed object.

More information

See Gravity Forms Docs: gform_zapier_feed_conditional_logic

Examples

Add additional logic rule

In this example, we add a new rule that checks if the specified field starts with “Test”.

add_filter('gform_zapier_feed_conditional_logic', 'set_logic', 10, 3);

function set_logic($logic, $form, $zap){
    $logic['rules'][] = array(
        'fieldId' => rgar($zap, 'zapier_conditional_field_id'),
        'operator' => 'starts_with',
        'value'    => 'Test',
    );
    return $logic;
}

Modify the existing logic rule

In this example, we modify the existing logic rule to check if the specified field is equal to “Approved”.

add_filter('gform_zapier_feed_conditional_logic', 'modify_logic', 10, 3);

function modify_logic($logic, $form, $zap){
    $logic['rules'][0]['operator'] = 'is';
    $logic['rules'][0]['value'] = 'Approved';
    return $logic;
}

Remove all logic rules

In this example, we remove all the existing logic rules.

add_filter('gform_zapier_feed_conditional_logic', 'remove_logic', 10, 3);

function remove_logic($logic, $form, $zap){
    $logic['rules'] = array();
    return $logic;
}

Add multiple logic rules

In this example, we add multiple logic rules to check if the specified field contains “Test” or “Sample”.

add_filter('gform_zapier_feed_conditional_logic', 'add_multiple_logic', 10, 3);

function add_multiple_logic($logic, $form, $zap){
    $logic['rules'][] = array(
        'fieldId' => rgar($zap, 'zapier_conditional_field_id'),
        'operator' => 'contains',
        'value'    => 'Test',
    );
    $logic['rules'][] = array(
        'fieldId' => rgar($zap, 'zapier_conditional_field_id'),
        'operator' => 'contains',
        'value'    => 'Sample',
    );
    return $logic;
}

Change the logic relationship

In this example, we change the logic relationship to “any” so that the feed will be processed if any of the rules are met.

add_filter('gform_zapier_feed_conditional_logic', 'change_logic_relationship', 10, 3);

function change_logic_relationship($logic, $form, $zap){
    $logic['relationship'] = 'any';
    return $logic;
}