gform_form_settings_page_VIEW

gform_form_settings_page_VIEW

DescriptionUsageParametersExamplesSource Code

Description
The gform_form_settings_page_{VIEW} action in Gravity Forms adds custom pages (i.e. 「views」) to the Form Settings section. This hook is used by Gravity Forms add-ons to add their settings pages.
Usage
Specify the view name after the gform_form_settings_page_ part of the hook name:
1add_action( 'gform_form_settings_page_VIEW', 'my_custom_function' );
Parameters
There are no parameters for this action.

Examples
This example demonstrates how to display page content for menu items added via the gform_form_settings_menu filter using the gform_form_settings_page_view hook. Note that the VIEW in the hook name is variable and should be replaced by your page name.
1234567891011121314151617181920212223// add a custom menu item to the Form Settings page menuadd_filter( 'gform_form_settings_menu', 'my_custom_form_settings_menu_item' );function my_custom_form_settings_menu_item( $menu_items ) {     $menu_items[] = array(        'name' => 'my_custom_form_settings_page',        'label' => __( 'My Custom Form Settings Page' )        );     return $menu_items;} // handle displaying content for our custom menu when selectedadd_action( 'gform_form_settings_page_my_custom_form_settings_page', 'my_custom_form_settings_page' );function my_custom_form_settings_page() {     GFFormSettings::page_header();     echo 'My Custom Form Settings!';     GFFormSettings::page_footer(); }
Source Code
This filter is located in GFFormSettings::form_settings_page() form_settings.php.

gform_form_settings_page_gravityformszapier

gform_form_settings_page_gravityformszapier

Description

Description
The 「gform_form_settings_page_gravityformszapier」 action in the Gravity Forms Zapier Add-On is a hook name that is dynamically generated. The hook gform_form_settings_page_{VIEW} in Gravity Forms is the actual hook that is run. The 「VIEW」 portion of the hook name is replaced with the 「gravityformszapier」 text.
Go to gform_form_settings_page_{VIEW} for details on using this hook.

gform_form_settings_menu

gform_form_settings_menu

DescriptionUsageParametersExamplesSource Code

Description

Add new or modify default menu items which will appear in the Form Settings section menu.

Usage

add_filter( 'gform_form_settings_menu', 'my_custom_function' );

Parameters

$menu_items arrayAn array of menu items to be displayed on the Form Settings page menu.

Examples

This example demonstrates how you can add a custom menu item to the Form Settings page menu. It also demonstrates (with the use of the gform_form_settings_page_view) how to display content for this page when selected.

// add a custom menu item to the Form Settings page menu
add_filter( 'gform_form_settings_menu', 'my_custom_form_settings_menu_item' );
function my_custom_form_settings_menu_item( $menu_items ) {

$menu_items[] = array(
'name' => 'my_custom_form_settings_page',
'label' => __( 'My Custom Form Settings Page' ),
'icon' => 'dashicons-flag dashicons'
);

return $menu_items;
}

// handle displaying content for our custom menu when selected
add_action( 'gform_form_settings_page_my_custom_form_settings_page', 'my_custom_form_settings_page' );
function my_custom_form_settings_page() {

GFFormSettings::page_header();

echo 'My Custom Form Settings!';

GFFormSettings::page_footer();

}

Source Code

This filter is located in GFFormSettings::get_tabs() in form_settings.php.

gform_form_settings_initial_values

gform_form_settings_initial_values

DescriptionUsageParametersExamples1. Enable HoneypotPlacementSinceSource Code

Description

The filter gform_form_settings_initial_values allows the initial values that will be populated into the form settings to be overridden.

Usage

The filter which would run for all forms would be used like so:

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

Parameters

$initial_values arrayAn associative array of setting names and their initial values.$form Form ObjectThe form currently being edited.

Examples

1. Enable Honeypot

add_filter( 'gform_form_settings_initial_values', function( $initial_values, $form ) {
$initial_values['enableHoneypot'] = true;

return $initial_values;
}, 10, 2 );

Placement

This code should be placed in the functions.php file of your active theme or a custom functions plugin.

Since

This filter was added in Gravity Forms v2.5.

Source Code

This filter is located in GFFormSettings::get_initial_values() in form_settings.php.

gform_form_settings_fields

gform_form_settings_fields

DescriptionUsageParametersExamplesAdd a new fieldPlacementSinceSource Code

Description

The gform_form_settings_fields filter is used to customize the available settings on the Form Settings page.

Usage

The filter which runs for all would be used like so:

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

You can also target a specific form by adding the form id after the hook name.

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

Parameters

$fields array
The Form Settings fields. See the Settings API for details about how the fields are defined.

$form Form Object
The current form.

Examples

Add a new field

This example would add a hidden field to the Form Options section of the Form Settings page.

add_filter( 'gform_form_settings_fields', function ( $fields, $form ) {
$fields['form_options']['fields'][] = array( 'type' => 'hidden', 'name' => 'my_custom_hidden_field' );

return $fields;
}, 10, 2 );

Placement

This code should be placed in the functions.php file of your active theme or a custom functions plugin.

Since

This filter was added in Gravity Forms v2.5.

Source Code

This filter is located in GFFormSettings::form_settings_fields() in form_settings.php.

gform_form_settings_before_save

gform_form_settings_before_save

DescriptionUsageParametersExamplesSource Code

Description
Modify the form object before saving on the Form Settings page. Useful for saving custom settings added via the gform_form_settings filter.
Usage
add_filter("gform_form_settings_before_save", "my_custom_function");

Parameters

$form Form Object
The current form object being edited.

Examples
This example demonstrates how you can save custom settings added via the gform_form_settings filter to the form object using the gform_form_settings_before_save filter.

';

return $settings;
}

// save your custom form setting
add_filter('gform_form_settings_before_save', 'save_my_custom_form_setting');
function save_my_custom_form_setting($form) {
$form['my_custom_setting'] = rgpost('my_custom_setting');
return $form;
}

?>

Source Code
This filter is located in form_settings.php.

gform_form_pre_update_entry

gform_form_pre_update_entry

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
Allows the form object to be modified before the entry is updated by an add-on or the API.
Usage
The following would apply to all forms:
add_filter( 'gform_form_pre_update_entry', 'your_function_name', 10, 3 );

To target a specific form, append the form id to the hook name. (format: gform_form_pre_update_entry_FORMID)
add_filter( 'gform_form_pre_update_entry_1', 'your_function_name', 10, 3 );

Parameters

$form Form Object
The current form.

$entry Entry Object
The current entry.

$entry_id int
The ID of the current entry.

Example
The example below removes one of the form fields from the Form Object so that it is not updated with the entry data.
add_filter( 'gform_form_pre_update_entry', 'modify_form', 10, 3 );
function modify_form( $form, $entry, $entry_id ){
$fields = $form['fields'];
foreach ( $fields as $field ){
if ( $field['label'] == 'Test') {
continue;
}
$new_fields[] = $field;
}
$form['fields'] = $new_fields;
return $form;
}

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 1.9.9.
Source Code
This filter is located in GFAPI::update_entry() in includes/api.php and
GF_Forms_Model_Legacy::update_entry() in includes/legacy/forms_model_legacy.php.

gform_form_pre_results

gform_form_pre_results

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to modify the Form object prior to calculating the results in the results admin page. The results page is currently only used by add-ons that implement the Add-On Framework.
Usage
1add_filter( 'gform_form_pre_results', 'your_function_name' );
You can also target a specific form by adding the form id after the hook name. (format: gform_form_pre_results_FORMID)
1add_filter( 'gform_form_pre_results_10', 'your_function_name' );

Parameters

$form array
The form object.

Examples
This example adds the field id to the field labels.
1234567add_filter( 'gform_form_pre_results', 'modify_results_fields' );function modify_results_fields( $form ) {    foreach ( $form['fields'] as &$field ) {        $field['label'] .= sprintf( " (Field ID: %d)", $field['id'] );    }    return $form;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
1apply_filters( "gform_form_pre_results_$form_id", apply_filters( 'gform_form_pre_results', $form ) );
This filter is located in GFResults::results_page() and GFResults::ajax_get_results() in includes/addon/class-gf-results.php.

gform_form_post_get_meta

gform_form_post_get_meta

DescriptionUsageParametersExamples1. Populate checkbox field2. Return admin labels in REST API requestPlacementSource CodeSince

Description
This filter can be used to manipulate the Form Object; it is executed when the form meta is retrieved. Any changes made to the form object via this filter would affect form render, validation, submission, and the form in the admin.
When using this filter you wouldn』t need to make the same change using the gform_pre_render, gform_pre_validation, gform_pre_submission_filter, or gform_admin_pre_render filters.
Usage
The following would apply to all forms.
1add_filter( 'gform_form_post_get_meta', 'your_function_name' );
To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_form_post_get_meta_FORMID)
1add_filter( 'gform_form_post_get_meta_6', 'your_function_name' );

Parameters

$form Form Object
The current form to be filtered.

Examples
1. Populate checkbox field
The following example dynamically populates a checkbox field with a list of published posts
12345678910111213141516171819202122232425262728293031323334353637//NOTE: update the '221' to the ID of your formadd_filter( 'gform_form_post_get_meta_221', 'populate_checkbox' );function populate_checkbox( $form ) {     foreach( $form['fields'] as &$field )  {         //NOTE: replace 3 with your checkbox field id        $field_id = 3;        if ( $field->id != $field_id ) {            continue;        }         // you can add additional parameters here to alter the posts that are retreieved        // more info: [http://codex.wordpress.org/Template_Tags/get_posts](http://codex.wordpress.org/Template_Tags/get_posts)        $posts = get_posts( 'numberposts=-1&post_status=publish' );         $input_id = 1;        foreach( $posts as $post ) {             //skipping index that are multiples of 10 (multiples of 10 create problems as the input IDs)            if ( $input_id % 10 == 0 ) {                $input_id++;            }             $choices[] = array( 'text' => $post->post_title, 'value' => $post->post_title );            $inputs[] = array( 'label' => $post->post_title, 'id' => "{$field_id}.{$input_id}" );             $input_id++;        }         $field->choices = $choices;        $field->inputs = $inputs;     }     return $form;}
2. Return admin labels in REST API request
The following example shows how a form, in this case id #93, can be configured to return the admin labels when getting entries via the REST API with the _labels argument.
1234567891011121314add_filter( 'gform_form_post_get_meta_93', function ( $form ) {    if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST  || ! rgget( '_labels' ) ) {        return $form;    }     foreach ( $form['fields'] as $field ) {        if ( $field->displayOnly ) {            continue;        }        $field->set_context_property( 'use_admin_label', true );    }     return $form;} );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
1$form = gf_apply_filters( 'gform_form_post_get_meta', $form_id, $form );
This filter is located in GFFormDisplay::get_form_meta() in form_display.php.
Since
The form specific version of this filter was added in Gravity Forms 1.9.6.

gform_form_notification_page

gform_form_notification_page

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
Filters the form to be used in the notification page.
Usage
The following would apply to all forms:
add_filter( 'gform_form_notification_page', 'your_function_name', 10, 2 );

To target a specific form, append the form id to the hook name. (format: gform_form_notification_page_FORMID)
add_filter( 'gform_form_notification_page_1', 'your_function_name', 10, 2 );

Parameters

$form Form Object
The current form.

$notification_id int
The notification id.

Example
The example below assumes a master form has been created (id 79) with all the notifications needed. When going to a different form and editing a notification, all the ones from the master form will be saved to your new form. Any changes made to notifications on your new form would be overwritten by the master form』s notifications once a notification is saved. This can be used to control the notifications on forms.
add_filter( 'gform_form_notification_page', 'use_master_form', 10, 2 );
function use_master_form( $form, $notification_id ){
if ($form['id'] == '45'){
//use master form with notifications to be used for all forms.
$form = GFFormsModel::get_form_meta(79);
}

return $form;

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 1.8.6.
Source Code
This filter is located in GFNotification::notification_edit_page() in notification.php.