The gform_field_groups_form_editor filter in Gravity Forms is used to modify the field groups in the Form Editor before fields are added, allowing control over what displays.
Usage
add_filter('gform_field_groups_form_editor', 'your_function_name', 10, 1);
Parameters
$field_groups
(array): The field groups, including group name, label, and fields.
More information
See Gravity Forms Docs: gform_field_groups_form_editor
Examples
Change the label for Standard Fields to Testing
This example changes the label for Standard Fields to “Testing”.
add_filter('gform_field_groups_form_editor', 'change_title', 10, 1); function change_title($field_groups) { foreach ($field_groups as &$group) { if ($group['name'] == 'standard_fields') { $group['label'] = 'Testing'; } } return $field_groups; }
Place this code snippet in the functions.php
file of your active theme.
Add a custom field group
This example adds a custom field group called “Custom Group” with a custom field called “My Custom Field”.
add_filter('gform_field_groups_form_editor', 'add_custom_field_group', 10, 1); function add_custom_field_group($field_groups) { $field_groups[] = array( 'name' => 'custom_group', 'label' => 'Custom Group', 'fields' => array( array( 'class' => 'button', 'data-type' => 'my_custom_field', 'value' => 'My Custom Field' ) ) ); return $field_groups; }
Place this code snippet in the functions.php
file of your active theme.
Remove a specific field from the Advanced Fields group
This example removes the “Name” field from the Advanced Fields group.
add_filter('gform_field_groups_form_editor', 'remove_name_field', 10, 1); function remove_name_field($field_groups) { foreach ($field_groups as &$group) { if ($group['name'] == 'advanced_fields') { foreach ($group['fields'] as $key => $field) { if ($field['data-type'] == 'name') { unset($group['fields'][$key]); } } } } return $field_groups; }
Place this code snippet in the functions.php
file of your active theme.
Change the order of field groups
This example changes the order of field groups by moving the Pricing Fields group to the first position.
add_filter('gform_field_groups_form_editor', 'change_field_groups_order', 10, 1); function change_field_groups_order($field_groups) { $pricing_fields_key = array_search('pricing_fields', array_column($field_groups, 'name')); if ($pricing_fields_key !== false) { $pricing_fields = $field_groups[$pricing_fields_key]; unset($field_groups[$pricing_fields_key]); array_unshift($field_groups, $pricing_fields); } return $field_groups; }
Place this code snippet in the functions.php
file of your active theme.