gform_admin_notification_attachments

gform_admin_notification_attachments

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter can be used to add attachments to the admin notification email.

This hook has been deprecated in v. 1.7. Please use gform_notification instead.

Usage
1add_filter( 'gform_admin_notification_attachments', 'add_attachment', 10, 3 );
You can also target a specific form by adding the form id after the hook name.
12//This filter declaration targets a form whose id is 6add_filter( 'gform_admin_notification_attachments_6', 'add_attachment', 10, 3 );

Parameters

$attachments string, array
The attachments to be filtered. It can be a simple strings containing for file path for one attachments or an array of strings for multiple attachments.

$entry Entry Object
Current entry object.

$form Form Object
Current form object.

Examples
This example attaches all file upload fields in the form to the admin notification email.
1234567891011121314151617add_filter( 'gform_admin_notification_attachments_4', 'add_attachment', 10, 3 );function add_attachment( $attachments, $lead, $form ) {    $fileupload_fields = GFCommon::get_fields_by_type( $form, array( 'fileupload' ) );    if ( ! is_array( $fileupload_fields ) ) {        return $attachments;    }    $attachments = array();    $upload_root = RGFormsModel::get_upload_root();    foreach ( $fileupload_fields as $field ) {        $url = $lead[ $field['id'] ];        $attachment = preg_replace( '|^(.*?)/gravity_forms/|', $upload_root, $url );        if ( $attachment ) {            $attachments[] = $attachment;        }    }    return $attachments;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in common.php

gform_after_delete_field

gform_after_delete_field

DescriptionUsageParametersExamplesSource Code

Description
Use this action hook to perform actions right after a field is deleted from a form.
Usage
add_action( 'gform_after_delete_field', 'do_cleanup', 10, 2 );

Parameters

$form_id integer
ID of current form.

$field_id integer
ID of deleted field.

Examples
This example adds a log file entry when a field is deleted.
add_action( 'gform_after_delete_field', 'log_deleted_field', 10, 2 );
function log_deleted_field( $form_id, $field_id ) {
$log_file = ABSPATH . '/gf_deleted_fields.log';
$f = fopen( $log_file, 'a' );
$user = wp_get_current_user();
fwrite( $f, date( 'c' ) . " - Field deleted by {$user->user_login}. Form ID: {$form_id}. Field ID: {$field_id} n" );
fclose( $f );
}

Source Code
This action hook is located in GFFormsModel::delete_field() in form_model.php.

gform_address_street

gform_address_street

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address street field and can be used to modify the 「Street」 label.
Usage
Applies to all forms.
add_filter( 'gform_address_street', 'change_address_street', 10, 2 );

Applies to a specific form. In this case, form id 5.
add_filter( 'gform_address_street_5', 'change_address_street', 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 street label:
add_filter( 'gform_address_street', 'change_address_street', 10, 2 );
function change_address_street( $label, $form_id ) {
return "Address Street";
}

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_advancedpostcreation_post

gform_advancedpostcreation_post

DescriptionUsageParametersExamplesChange the post contentChange the post slugChange the post excerptPlacementSinceSource Code

Description

Modifies the Post object before it is created.

Note: This filter should not be used to override the Post ID value. Doing it would cause unexpected results during the Post creation process.

Usage

The following would apply to all forms:

add_filter( 'gform_advancedpostcreation_post', 'your_function_name', 10, 4 );

To target a specific form, append the form id to the hook name. (format: gform_advancedpostcreation_post_FORMID)

add_filter( 'gform_advancedpostcreation_post_1', 'your_function_name', 10, 4 );

Parameters

$post boolThe post object to be created.

Array
(
[post_status] => publish
[post_type] => post
[post_title] => testing
[comment_status] => closed
[ping_status] => closed
[ID] => 328
[post_content] => test,test, test, test,
[post_excerpt] => Excerpt Test
[post_author] => 1
[post_date_gmt] => 2019-04-30 20:40:00
)

$feed Feed ObjectThe current feed object.$entry Entry ObjectThe current entry object.$form Form ObjectThe current form object.

Examples

Change the post content

add_filter( 'gform_advancedpostcreation_post', 'change_post', 10, 4 );
function change_post( $post, $feed, $entry, $form){
$post['post_content'] = 'This is a test';
return $post;
}

Change the post slug

This example uses merge tags to change the post slug which is taken from the post_name property. This time we have limited the scope of the snippet to form id 1 by adding the form id to the filter name.

add_filter( 'gform_advancedpostcreation_post_1', function ( $post, $feed, $entry, $form ) {
$slug = '{first name:1.3} {last name:1.6} {date:2:year}-{date:2:month}';
$post['post_name'] = sanitize_title( GFCommon::replace_variables( $slug, $form, $entry, false, false, false, 'text' ) );
return $post;
}, 10, 4 );

Change the post excerpt

This examples uses a specific paragraph field to be written to the post excerpt. Be sure to change your code to match the field id which you are using for inputting the excerpt.

add_filter( 'gform_advancedpostcreation_post', 'change_post_excerpt', 10, 4 );
function change_post_excerpt( $post, $feed, $entry, $form){
$post['post_excerpt'] = rgar( $entry, 6 ); // Field 6 is the Excerpt
return $post;
}

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in the Gravity Forms Advanced Post Creation add-on version 1.0.

Source Code

This filter is located in GF_Advanced_Post_Creation::create_post() in class-gf-advancedpostcreation.php.

gform_admin_pre_render

gform_admin_pre_render

DescriptionUsageParametersExamples1. Populate a choice based field.2. Enable entry meta in feed conditional logicPlacementSource Code

Description
This filter is executed before the entry detail is displayed and can be used to manipulate the Form Object prior to rendering the entry.
Usage
Applies to all forms
add_action( 'gform_admin_pre_render', 'pre_render_function' );

Applies to a specific form. In this case, form Id 5
add_action( 'gform_admin_pre_render_5', 'pre_render_function' );

Parameters

$form Form Object
The current form to be filtered.

Examples
1. Populate a choice based field.
This example dynamically populates a drop down field with posts that are in the Business category.
add_filter( 'gform_admin_pre_render', 'populate_dropdown' );
function populate_dropdown( $form ) {

//only populating drop down for form id 5
if ( $form['id'] != 5 )
return $form;

//Reading posts for "Business" category;
$posts = get_posts( 'category=Business' );

//Creating drop down item array.
$items = array();

//Adding initial blank value.
$items[] = array( 'text' => '', "value" => '' );

//Adding post titles to the items array
foreach ( $posts as $post )
$items[] = array( 'value' => $post->post_title, 'text' => $post->post_title );

//Adding items to field id 8. Replace 8 with your actual field id. You can get the field id by looking at the input name in the markup.
foreach ( $form['fields'] as &$field ) {
if ( $field->id == 8 ) {
$field->choices = $items;
}
}

return $form;
}

2. Enable entry meta in feed conditional logic
This example shows how entry meta, such as the quiz score, can be enabled for use when configuring conditional logic rules on the ActiveCampaign feed.
add_filter( 'gform_admin_pre_render', function ( $form ) {
if ( rgget( 'page' ) == 'gf_edit_forms' && rgget( 'view' ) == 'settings' && rgget( 'subview' ) == 'gravityformsactivecampaign' ) {
echo "';
}

return $form;
} );

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in the following methods:

GFEntryDetail::lead_detail_page() in entry_detail.php
GFEntryDetail::lead_detail_edit() in entry_detail.php
GFFormDetail::forms_page() in form_detail.php
GFFormSettings::form_settings_ui() in form_settings.php
GFFormSettings::confirmations_edit_page() in form_settings.php
GFNotification::get_notification_ui_settings() in notification.php

gform_address_street2

gform_address_street2

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the address street 2 field and can be used to modify the 「Street 2」 label.
Usage
Applies to all forms.
1add_filter( 'gform_address_street2', 'change_address_street2', 10, 2 );
Applies to a specific form. In this case, form id 5.
1add_filter( 'gform_address_street2_5', 'change_address_street2', 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 street 2 label:
1234add_filter( 'gform_address_street2', 'change_address_street2', 10, 2 );function change_address_street2( $label, $form_id ) {    return "Address Street 2";}
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_advancedpostcreation_pre_update_post

gform_advancedpostcreation_pre_update_post

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description

Allow custom actions to be performed before the post is updated.

Usage

The following would apply to all forms:

add_action( 'gform_advancedpostcreation_pre_update_post', 'your_function_name', 10, 3 );

To target a specific form, append the form id to the hook name. (format: gform_advancedpostcreation_pre_update_post_FORMID):

add_action( 'gform_advancedpostcreation_pre_update_post_1', 'your_function_name', 10, 3 );

Parameters

$post array The post to be updated. Array returned is the WP get_post function.$feed Feed ObjectThe feed being processed.$entry Entry Object The entry linked to the post.

Examples

add_action( 'gform_advancedpostcreation_pre_update_post', 'pre_update_your_post', 10, 3 );
function pre_update_your_post ($post, $feed, $entry) {
// do something
}

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in Gravity Forms Advanced Post Creation add-on version 1.0

Source Code

This filter is located in GF_Advanced_Post_Creation:update() in class-post-update-handler.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_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_activecampaign_note

gform_activecampaign_note

DescriptionUsageParametersExamples1. Customize the note.PlacementSinceSource Code

Description
Filter the note that will be created and associated with the given contact. Supports filtering which contact and/or list the note should be associated with.
Usage
The following would apply to all forms.
1add_filter( 'gform_activecampaign_note', 'your_function_name', 10, 3 );
The following would apply to a specific form.
1add_filter( 'gform_activecampaign_note_FORMID', 'your_function_name', 10, 3 );

Parameters

$note array
Properties that will be used to create and assign the note.

$contact_id int
Contact ID to associate the note with.

$list_id int
List ID to associate the note with.

$note string
Actual note content. HTML will be stripped.

$feed array
Current Active Campaign feed being processed.

$entry array
Current entry being processed.

$form array
Current form being processed.

Examples
1. Customize the note.
The following example shows how you can customize the note.
1234add_filter( 'gform_activecampaign_note', function( $note ) {    $note['note'] = 'My custom note.';    return $note;} );
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 Active Campaign 1.6.
Source Code
This filter is located in GFActiveCampaign::process_feed() in includes/class-gf-activecampaign.php.