Using Gravity Forms ‘gform_use_post_value_for_conditional_logic_save_entry’ PHP filter

The gform_use_post_value_for_conditional_logic_save_entry filter in Gravity Forms specifies whether to fetch values from the $_POST when evaluating a field’s conditional logic. Defaults to true for new entries and false for existing entries.

Usage

Apply the filter to all forms:

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

Limit the filter’s scope to a specific form by appending the form ID:

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

Parameters

  • $read_value_from_post (array): Should the value be fetched from the $_POST?
  • $form (Form Object): The current form object.
  • $entry (Entry Object): The current entry object.

More information

See Gravity Forms Docs: gform_use_post_value_for_conditional_logic_save_entry

Examples

Enable fetching from $_POST by default

Fetch values from $_POST for all forms when evaluating conditional logic:

add_filter('gform_use_post_value_for_conditional_logic_save_entry', '__return_true');

Disable fetching from $_POST for a specific form

Prevent fetching values from $_POST when evaluating conditional logic for form ID 7:

function disable_post_values_for_form_7($read_value_from_post, $form, $entry) {
    if ($form['id'] == 7) {
        return false;
    }
    return $read_value_from_post;
}
add_filter('gform_use_post_value_for_conditional_logic_save_entry', 'disable_post_values_for_form_7', 10, 3);

Fetch values from $_POST only for specific field types

Fetch values from $_POST for fields of type ‘checkbox’ when evaluating conditional logic:

function fetch_post_values_for_checkbox_fields($read_value_from_post, $form, $entry) {
    foreach ($form['fields'] as $field) {
        if ($field->type == 'checkbox') {
            return true;
        }
    }
    return $read_value_from_post;
}
add_filter('gform_use_post_value_for_conditional_logic_save_entry', 'fetch_post_values_for_checkbox_fields', 10, 3);

Use $_POST values only when certain form values are met

Fetch values from $_POST for form ID 8 only when a specific field has a certain value:

function use_post_values_based_on_condition($read_value_from_post, $form, $entry) {
    if ($form['id'] == 8 && rgpost('input_5') == 'yes') {
        return true;
    }
    return $read_value_from_post;
}
add_filter('gform_use_post_value_for_conditional_logic_save_entry', 'use_post_values_based_on_condition', 10, 3);

Modify behavior based on entry status

Fetch values from $_POST for a specific form only for new entries:

function fetch_post_values_for_new_entries($read_value_from_post, $form, $entry) {
    if ($form['id'] == 9 && empty($entry['id'])) {
        return true;
    }
    return $read_value_from_post;
}
add_filter('gform_use_post_value_for_conditional_logic_save_entry', 'fetch_post_values_for_new_entries', 10, 3);