gform_address_city

gform_address_city

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address city field and can be used to modify the 「City」 label.
Usage
Applies to all forms.
1add_filter( 'gform_address_city', 'change_address_city', 10, 2 );
Applies to a specific form. In this case, form id 5.
1add_filter( 'gform_address_city_5', 'change_address_city', 10, 2 );
Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default address city label:
1234add_filter( 'gform_address_city', 'change_address_city', 10, 2 );function change_address_city( $label, $form_id ) {    return "Town";}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in js.php and GF_Field_Address::get_field_input() in includes/fields/class-gf-field-address.php.

gform_addon_pre_process_feeds

gform_addon_pre_process_feeds

DescriptionUsageParametersExamples1. Convert User Registration 「Create」 Feeds to 「Update」 Feeds if User is Logged-in2. Override the User Registration Role Setting3. Override Mailchimp Feed SettingPlacementSource CodeSince

Description
Modify all possible feeds before they are processed by Gravity Forms.
Usage
Generic: applies to feeds for all add-ons and all forms.
1add_filter( 'gform_addon_pre_process_feeds', 'your_function_name', 10, 3 );
Generic, Form-specific: applies to feeds for all add-ons for a specific form.
1add_filter( 'gform_addon_pre_process_feeds_{FORM_ID}', 'your_function_name' );
Addon-specific: applies to feeds for a specific add-on for all forms.
1add_filter( 'gform_{ADDON_SLUG}_pre_process_feeds', 'your_function_name', 10, 3 );
See the Gravity Forms Add-On Slugs article for a list of possible slugs.
Addon-specific, Form-specific: applies to feeds for a specific add-on and form.
1add_filter( 'gform_{ADDON_SLUG}_pre_process_feeds_{FORM_ID}', 'your_function_name' );

Parameters

$feeds array
An array of Feed Objects.

$entry Entry Object
Current entry for which $feeds will be processed.

$form Form Object
Current form object.

Examples
1. Convert User Registration 「Create」 Feeds to 「Update」 Feeds if User is Logged-in
12345678910add_filter( 'gform_gravityformsuserregistration_pre_process_feeds', function( $feeds ) {     if ( is_user_logged_in() && is_array( $feeds ) ) {        foreach( $feeds as &$feed ) {            $feed['meta']['feedType'] = 'update';        }    }     return $feeds;} );
2. Override the User Registration Role Setting
This example shows how the choice selected for the User Registration feed of form 2 can be overridden with the value of a form field during form submission. The form field choices would need to be configured with the roles.
12345678add_filter( 'gform_gravityformsuserregistration_pre_process_feeds_2', function ( $feeds, $entry ) {    foreach ( $feeds as &$feed ) {        // use the value submitted for field 5 as the role        $feed['meta']['role'] = rgar( $entry, '5' );    }     return $feeds;}, 10, 2 );
3. Override Mailchimp Feed Setting
This example shows how you can override a setting on a Mailchimp feed. See the Mailchimp Feed Meta article for the available settings.
1234567add_filter( 'gform_gravityformsmailchimp_pre_process_feeds', function ( $feeds, $entry ) {    foreach ( $feeds as &$feed ) {        $feed['meta']['double_optin'] = false;    }     return $feeds;}, 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in /includes/addon/class-gf-feed-addon.php.
Since
This filter was added in Gravity Forms 2.0-beta-2.

gform_addon_navigation

gform_addon_navigation

DescriptionUsageParametersExamplesSource Code

Description
Use this filter to add a sub-menu item under the 「Forms」 menu.
Usage
1add_filter( 'gform_addon_navigation', 'add_menu_item' );
Parameters

$menu_items array
Current list of menu items to be filtered, in the following format:
123456array(    array(  "name" => "gf_campaignmonitor",        "label" => "Campaign Monitor",        "callback" => "campaignmonitor_page",        "permission" => "gravityforms_campaignmonitor"););

Examples
This example adds a new sub-menu item under 「Forms」.
12345add_filter( 'gform_addon_navigation', 'add_menu_item' );function add_menu_item( $menu_items ) {    $menu_items[] = array( "name" => "new_submenu_name", "label" => "New Submenu", "callback" => "submenu_handler", "permission" => "edit_posts" );    return $menu_items;}
Source Code
This filter is located in GFForms::create_menu() in gravityforms.php

gform_addon_field_value

gform_addon_field_value

DescriptionUsageParametersExamples1. Change Value of Specific Field2. Use Choice Text Instead of ValuePlacementSource CodeSince

Description
This filter can be used to modify a value before it is sent to a third-party by one of the Add-On Framework based add-ons. If you want to filter the value for a specific add-on you can use gform_short_slug_field_value.
Usage
The base filter which would run for all forms and all fields would be used like so:
add_filter( 'gform_addon_field_value', 'your_function_name', 10, 5 );

To target a specific form append the form id to the hook name. (format: gform_addon_field_value_FORMID)
add_filter( 'gform_addon_field_value_10', 'your_function_name', 10, 5 );

To target a specific field append both the form id and the field id to the hook name. (format: gform_addon_field_value_FORMID_FIELDID)
add_filter( 'gform_addon_field_value_10_3', 'your_function_name', 10, 5 );

Parameters

$field_value string
The value to be modified.

$form Form Object
The form currently being processed.

$entry Entry Object
The entry currently being processed.

$field_id string
The id of the field currently being processed.

$slug string
The add-on slug, including the gravityforms prefix. See the Gravity Forms Add-On Slugs article for a list of possible slugs.

Examples
1. Change Value of Specific Field
This example shows how you can change the value of field 3 on form 10 before it is passed to any of the feed add-ons.
add_filter( 'gform_addon_field_value_10_3', function ( $field_value, $form, $entry, $field_id ) {

return 'your new value';
}, 10, 4 );

2. Use Choice Text Instead of Value
This example shows how you can replace the value of a choice based survey field with the choice text.
add_filter( 'gform_addon_field_value', 'gf_get_choice_text', 10, 5 );
function gf_get_choice_text( $field_value, $form, $entry, $field_id, $slug ) {
$field = RGFormsModel::get_field( $form, $field_id );

if ( is_object( $field ) && $field->type == 'survey' ) {
$field_value = $field->get_value_export( $entry, $field_id, true );
}

return $field_value;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
$field_value = gf_apply_filters( array( 'gform_addon_field_value', $form['id'], $field_id ), $field_value, $form, $entry, $field_id, $this->_slug );

This filter is located in GFAddOn::get_field_value() in includes/addon/class-gf-addon.php.
Since
This filter was added in Gravity Forms 1.9.15.12.

gform_addon_field_map_choices

gform_addon_field_map_choices

DescriptionUsageParametersExamples1. Add new choice to all add-onsPlacementSource CodeSince

Description
The gform_addon_field_map_choices filter can be used to override the choices available in the field map drop down.
This filter is depreacted since version 2.5. Use the gform_field_map_choices filter instead.
Usage
Generic: applies to all add-ons and all forms.
1add_filter( 'gform_addon_field_map_choices', 'your_function_name', 10, 3 );
Addon-specific: applies to a specific add-on for all forms. Requires a minimum PHP version of 5.3.
1add_filter( 'gform_{ADDON_SLUG}_field_map_choices', 'your_function_name', 10, 3 );
See the Gravity Forms Add-On Slugs article for a list of possible slugs.

Parameters

$fields array
The value and label properties for each choice.

$form_id integer
The ID of the form currently being configured.

$field_type null | array
Null or the field types to be included in the drop down.

$exclude_field_types null | array | string
Null or the field type(s) to be excluded from the drop down.

Examples
1. Add new choice to all add-ons
12345add_filter( 'gform_addon_field_map_choices', function( $fields, $form_id, $field_type, $exclude_field_types ) {    $fields[] = array( 'label' => 'The new choice', 'value' => 'new_choice' );     return $fields;}, 10, 4 );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFAddOn::get_field_map_choices() in /includes/addon/class-gf-addon.php.
Since
This filter was added in Gravity Forms 2.0.7.11.

gform_addon_feed_settings_fields

gform_addon_feed_settings_fields

DescriptionUsageParametersExamples1. Add a Custom Setting to the First Section of All Feeds2. Add a Custom Setting After the 「Send Email」 Setting for All User Registration Feeds3. Remove 『Password』 Setting for User Registration Feeds for a Specific Form4. Add a Custom Setting to Certain Payment Add-OnsFurther ReadingPlacementSource CodeSince

Description
Filter the feed settings fields (typically before they are rendered on the Feed Settings edit view).
Usage
The base filter which would run for all add-on feeds would be used like so:
add_filter( 'gform_addon_feed_settings_fields', 'your_function_name', 10, 2 );

You can target a specific add-on with the following variation of this hook:
add_filter( 'gform_{ADDON_SLUG}_feed_settings_fields', 'your_function_name', 10, 2 );

See the Gravity Forms Add-On Slugs article for a list of possible slugs.

Parameters

$feed_settings_fields array
An array of feed settings fields which will be displayed on the Feed Settings edit view. See the Settings API for further details on the structure of the array.

$addon object
The current instance of the GFAddon object which extends GFFeedAddOn or GFPaymentAddOn (i.e. GFCoupons, GF_User_Registration, GFStripe).

Examples
1. Add a Custom Setting to the First Section of All Feeds
add_filter( 'gform_addon_feed_settings_fields', 'add_custom_addon_setting', 10, 2 );
function add_custom_addon_setting( $feed_settings_fields, $addon ) {

$feed_settings_fields[0]['fields'][] = array(
'name' => 'my_custom_setting',
'label' => 'My Custom Setting',
'type' => 'text'
);

return $feed_settings_fields;
}

2. Add a Custom Setting After the 「Send Email」 Setting for All User Registration Feeds
This example shows how the add_field_after() helper can be used to add a new setting after a specific existing setting.
add_filter( 'gform_gravityformsuserregistration_feed_settings_fields', function( $feed_settings_fields, $addon ) {

$feed_settings_fields = $addon->add_field_after( 'sendEmail', array(
array(
'name' => 'my_custom_setting',
'label' => 'My Custom Setting',
'type' => 'text'
)
), $feed_settings_fields );

return $feed_settings_fields;
}, 10, 2 );

3. Remove 『Password』 Setting for User Registration Feeds for a Specific Form
This example shows how the remove_field() helper can be used to remove one of the settings.
add_filter( 'gform_gravityformsuserregistration_feed_settings_fields', function( $feed_settings_fields, $addon ) {

$form = $addon->get_current_form();
if( $form['id'] == 1 ) {
$feed_settings_fields = $addon->remove_field( 'password', $feed_settings_fields );
}

return $feed_settings_fields;
}, 10, 2 );

4. Add a Custom Setting to Certain Payment Add-Ons
This example shows how an add-on which uses the Add-On Framework, in this example it』s the User Registration Add-On, can add a custom setting to add-ons which extend GFPaymentAddOn and support subscription cancellations.
public function init() {
parent::init();
add_filter( 'gform_addon_feed_settings_fields', array( $this, 'add_subscription_feed_setting' ), 10, 2 );
}
public function add_subscription_feed_setting( $feed_settings_fields, $addon ) {
$addon_supports_subscriptions = $addon instanceof GFPaymentAddOn && $addon->method_is_overridden( 'cancel', 'GFPaymentAddOn' );

if ( $addon_supports_subscriptions ) {

$ur_settings = array(
'title' => esc_html__( 'User Registration Options', 'gravityformsuserregistration' ),
'tooltip' => sprintf( '

%s

%s', esc_html__( 'User Registration Options', 'gravityformsuserregistration' ), esc_html__( 'The selected form also has a User Registration feed. These options allow you to specify how you would like the PayPal and User Registration Add-ons to work together.', 'gravityformuserregistration' ) ),
'fields' => array(),
'dependency' => array( 'field' => 'transactionType', 'values' => array( 'subscription' ) ),
);

$ur_settings['fields'][] = array(
'name' => 'cancellationActionUser',
'label' => esc_html__( 'Update User on Cancel', 'gravityformsuserregistration' ),
'type' => 'checkbox_and_select',
'checkbox' => array(
'label' => esc_html__( 'Update user when subscription is cancelled.', 'gravityformsuserregistration' )
),
'select' => array(
'choices' => $this->get_update_user_actions_choices()
),
);

$feed_settings_fields = array_merge( $feed_settings_fields, array( $ur_settings ) );
}

return $feed_settings_fields;
}

Further Reading
For more details on adding and removing fields from the settings, see the Helper Functions article.
The Settings API category includes a number of examples showing how you can implement various field types.
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFFeedAddOn::get_feed_settings_fields() in /includes/addons/class-gf-feed-addon.php.
Since
This filter was added in Gravity Forms 2.0.

gform_addon_app_settings_menu_{$SHORT_SLUG}

gform_addon_app_settings_menu_{$SHORT_SLUG}

DescriptionUsageParametersPlacementSource Code

Description
The 「gform_addon_app_settings_menu_」 plus {$SHORT_SLUG} filter in Gravity Forms controls the addition or removal of tabs within the Gravity Forms settings menu.
Usage
The Gravity Forms Add-On Slugs lists the short slugs for the available add-ons.
The following would add a settings tab and determine the callback for the defined slug:
add_filter( 'gform_addon_app_settings_menu_{$SHORT_SLUG}', 'your_function_name' );

The following would run for the Mailchimp add-on:
add_filter( 'gform_addon_app_settings_menu_mailchimp', 'your_function_name' );

The following would run for the 2Checkout add-on:
add_filter( 'gform_addon_app_settings_menu_2checkout', 'your_function_name' );

Parameters

$settings_tabs array
Any existing settings tabs. Controls each of the tabs and the callback.

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in class-gf-addon.php.

gform_addon_app_PAGE_TAB

gform_addon_app_PAGE_TAB

DescriptionUsageParametersPlacementSource Code

Description
This action fires when a page and tab is accessed within Gravity Forms.
Typically used to add content to custom settings tabs.
Usage
add_action( 'gform_addon_app_PAGE_TAB', 'your_function_name' );

Parameters
No parameters are provided for this action.

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This hook is located in class-gf-addon.php.

gform_addnote_button

gform_addnote_button

DescriptionUsageParametersExamplesPlacementSource Code

Description
The 「gform_addnote_button」 filter in Gravity Forms allows modification of the HTML of the 「Add Note」 button for Entry Notes on the Entry Detail page.
Usage
1add_filter( 'gform_addnote_button', 'your_function_name', 10, 1 );

Parameters

$note_button string
The HTML for the 「Add Note」 Button.

Examples
12345add_filter( 'gform_addnote_button', 'change_button', 10, 1 );function change_button( $note_button ){    $note_button = '';    return $note_button;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFEntryDetail::notes_grid() in entry_detail.php.

gform_add_meta()

gform_add_meta()

DescriptionUsageParametersExamplesSource Code

Description
The function 「gform_add_meta()」 adds the metadata associated with an entry in the Entry Meta table. The data will be serialized.
Usage
gform_add_meta( $entry_id, $meta_key, $meta_value, $form_id = null );

Parameters

$entry_id integer
The ID of the entry.

$meta_key string
The meta key of the meta value you wish to add.

$meta_value string
The value to be set as the new value for the specified meta key.

$form_id integer
The form ID of the entry. Optional (saves extra query if passed when creating the metadata).

Examples
This example inserts a value for a new meta key.
//inserts "This is test data" for the meta key "my_test_key" for entry id 14 for form id 1.
gform_add_meta(14, 'my_test_key', 'This is test data.', 1);

Source Code
This function is located in forms_model.php