The gform_filters_pre_results filter allows you to modify the filters used in the dropdown list of fields in the admin results page. This results page is primarily used by add-ons that implement the Add-On Framework.
Usage
add_filter('gform_filters_pre_results', 'your_function_name', 10, 2);
Parameters
- $filter_settings (array) – The array of filters.
- $form (Form Object) – The form object.
More information
See Gravity Forms Docs: gform_filters_pre_results
Examples
Remove payment related info fields from the filters
This example demonstrates how to remove payment related info fields from the filters.
add_filter('gform_filters_pre_results', 'remove_payment_filters', 10, 2); function remove_payment_filters($filter_settings, $form) { foreach ($filters as $i => $filter) { if (in_array($filter_settings['key'], array('payment_amount', 'payment_date', 'payment_status', 'transaction_id'))) { unset($filter_settings[$i]); } } return $filter_settings; }
Add custom filter
This example shows how to add a custom filter to the list.
add_filter('gform_filters_pre_results', 'add_custom_filter', 10, 2); function add_custom_filter($filter_settings, $form) { $filter_settings[] = array( 'key' => 'custom_filter', 'text' => __('Custom Filter', 'textdomain') ); return $filter_settings; }
Modify existing filter
This example demonstrates how to modify an existing filter.
add_filter('gform_filters_pre_results', 'modify_existing_filter', 10, 2); function modify_existing_filter($filter_settings, $form) { foreach ($filter_settings as &$filter) { if ($filter['key'] == 'some_filter_key') { $filter['text'] = __('New Filter Text', 'textdomain'); } } return $filter_settings; }
Remove all filters
This example shows how to remove all filters from the list.
add_filter('gform_filters_pre_results', 'remove_all_filters', 10, 2); function remove_all_filters($filter_settings, $form) { return array(); }
Conditionally modify filters
This example demonstrates how to modify filters based on the form ID.
add_filter('gform_filters_pre_results', 'conditionally_modify_filters', 10, 2); function conditionally_modify_filters($filter_settings, $form) { if ($form['id'] == 1) { foreach ($filter_settings as &$filter) { if ($filter['key'] == 'some_filter_key') { $filter['text'] = __('Modified Filter Text', 'textdomain'); } } } return $filter_settings; }