Using Gravity Forms ‘gform_form_settings_fields’ PHP filter

The gform_form_settings_fields filter in Gravity Forms allows you to customize the settings available on the Form Settings page and save these settings to the database.

Usage

The filter can be used for all forms like this:

add_filter( 'gform_form_settings_fields', 'your_function_name', 10, 2 );

To target a specific form, add the form id after the hook name:

add_filter( 'gform_form_settings_fields_{form_id}', 'your_function_name', 10, 2 );

Remember to replace {form_id} with your specific form id and your_function_name with your custom function.

Parameters

  • $settings_fields (array) – The existing settings fields.
  • $form (array) – The current form array.

More Information

See Gravity Forms Docs: gform_form_settings_fields
This filter was introduced in Gravity Forms version 2.5.

Examples

Adding a New Settings Field

To add a new settings field:

function add_my_custom_settings_field( $settings_fields, $form ) {
    // your custom code here

    // Adding a new settings field
    $settings_fields['Form Basics']['custom_field'] = array(
        'label'       => 'Custom Field',
        'type'        => 'text',
        'description' => 'This is a custom field',
        'class'       => 'medium'
    );

    return $settings_fields;
}
add_filter( 'gform_form_settings_fields', 'add_my_custom_settings_field', 10, 2 );

Modifying an Existing Settings Field

To modify an existing settings field:

function modify_my_custom_settings_field( $settings_fields, $form ) {
    // your custom code here

    // Modifying an existing settings field
    $settings_fields['Form Basics']['description']['label'] = 'Modified Label';

    return $settings_fields;
}
add_filter( 'gform_form_settings_fields', 'modify_my_custom_settings_field', 10, 2 );

Removing a Settings Field

To remove a settings field:

function remove_my_custom_settings_field( $settings_fields, $form ) {
    // your custom code here

    // Removing a settings field
    unset($settings_fields['Form Basics']['description']);

    return $settings_fields;
}
add_filter( 'gform_form_settings_fields', 'remove_my_custom_settings_field', 10, 2 );

Targeting a Specific Form

To add a custom field to a specific form (let’s say form with id 5):

function add_to_specific_form( $settings_fields, $form ) {
    // your custom code here

    // Adding to a specific form
    $settings_fields['Form Basics']['custom_field'] = array(
        'label'       => 'Custom Field',
        'type'        => 'text',
        'description' => 'This is a custom field',
        'class'       => 'medium'
    );

    return $settings_fields;
}
add_filter( 'gform_form_settings_fields_5', 'add_to_specific_form', 10, 2 );