gform_after_save_form

gform_after_save_form

DescriptionUsageParametersExamples1. Log form creation/update2. Add default fields on form creation3. Set default notification propertiesSource Code

Description
Use this action hook to perform actions right after a form is created or updated.
Usage
1add_action( 'gform_after_save_form', 'log_form_save', 10, 2 );

Parameters

$form Form Object
Current form.

$is_new bool
True if this is a new form being created. False if this is an existing form being updated.

Examples
1. Log form creation/update
This example adds a log file entry when a form is updated or created.
123456789101112add_action( 'gform_after_save_form', 'log_form_saved', 10, 2 );function log_form_saved( $form, $is_new ) {    $log_file = ABSPATH . '/gf_saved_forms.log';    $f = fopen( $log_file, 'a' );    $user = wp_get_current_user();    if ( $is_new ) {        fwrite( $f, date( 'c' ) . " - Form created by {$user->user_login}. Form ID: {$form["id"]}. n" );    } else {        fwrite( $f, date( 'c' ) . " - Form updated by {$user->user_login}. Form ID: {$form["id"]}. n" );    }    fclose( $f );}
2. Add default fields on form creation
This example shows how you can add some default fields to the form when creating new forms.
12345678910111213141516171819202122add_action( 'gform_after_save_form', 'add_default_fields', 10, 2 );function add_default_fields( $form, $is_new ) {    if ( $is_new ) {        $form['fields'] = array(            array(                'type'         => 'hidden',                'label'        => 'First Name',                'id'           => 1,                'defaultValue' => '{user:first_name}',                'formId'       => $form['id'],            ),            array(                'type'         => 'hidden',                'label'        => 'Email',                'id'           => 2,                'defaultValue' => 'user:user_email',                'formId'       => $form['id'],            ),        );        GFAPI::update_form( $form );    }}
3. Set default notification properties
This example shows how you can set the default notification properties when creating new forms.
123456789101112add_action( 'gform_after_save_form', 'set_default_notification_to', 10, 2 );function set_default_notification_to( $form, $is_new ) {    if ( $is_new ) {        foreach ( $form['notifications'] as &$notification ) {            $notification['to'] = '[email protected]';        }         $form['is_active'] = '1';         GFAPI::update_form( $form );    }}
Source Code
This action hook is located in GFFormDetail::save_form_info() in form_detail.php.

gform_after_submission

gform_after_submission

DescriptionUsageParametersExamples1. Update post after its creation2. Perform a custom action after creating posts with the Advanced Post Creation add-on3. Send entry data to third-party4. Access the entry by looping through the form fields5. Create a ticket in WSDesk6. Submit entries to Tripleseat7. Submit entries to SharpSpring8. Create an Events Calendar plugin event9. Check entry spam statusPlacementSource Code

Description

The gform_after_submission action hook is executed at the end of the submission process (after form validation, notification, and entry creation). Use this hook to perform actions after the entry has been created (i.e. feed data to third party applications).

The Entry Object is available to this hook and contains all submitted values.

This hook also runs for entries which are marked as spam. It does not run for submissions which fail the honeypot validation.

Usage

Applies to all forms.

add_action( 'gform_after_submission', 'after_submission', 10, 2 );

Applies to a specific form. In this case, form id 5.

add_action( 'gform_after_submission_5', 'after_submission', 10, 2 );

Parameters

$entry Entry Object The entry that was just created.$form Form Object The current form.

Examples

1. Update post after its creation

This example uses the gform_after_submission hook to change the post content, adding values from submitted fields, including an image field, to the post created as result of the form submission.

add_action( 'gform_after_submission', 'set_post_content', 10, 2 );
function set_post_content( $entry, $form ) {

//getting post
$post = get_post( $entry['post_id'] );

//changing post content
$post->post_content = 'Blender Version:' . rgar( $entry, '7' ) . "

" . rgar( $entry, '13' ) . "
";

//updating post
wp_update_post( $post );
}

2. Perform a custom action after creating posts with the Advanced Post Creation add-on

This example shows how to get the post ids when using the Advanced Post Creation Add-On.

add_action( 'gform_after_submission', 'custom_action_after_apc', 10, 2 );
function custom_action_after_apc( $entry, $form ) {

//if the Advanced Post Creation add-on is used, more than one post may be created for a form submission
//the post ids are stored as an array in the entry meta
$created_posts = gform_get_meta( $entry['id'], 'gravityformsadvancedpostcreation_post_id' );
foreach ( $created_posts as $post )
{
$post_id = $post['post_id'];
// Do your stuff here.
}
}

3. Send entry data to third-party

This example demonstrates a simple approach to posting submitted entry data to a third party application.

Note: The Webhooks Add-On can be used to perform requests like this with little or no coding required. See the Triggering Webhooks On Form Submissions article.

add_action( 'gform_after_submission', 'post_to_third_party', 10, 2 );
function post_to_third_party( $entry, $form ) {

$endpoint_url = 'https://thirdparty.com';
$body = array(
'first_name' => rgar( $entry, '1.3' ),
'last_name' => rgar( $entry, '1.6' ),
'message' => rgar( $entry, '3' ),
);
GFCommon::log_debug( 'gform_after_submission: body => ' . print_r( $body, true ) );

$response = wp_remote_post( $endpoint_url, array( 'body' => $body ) );
GFCommon::log_debug( 'gform_after_submission: response => ' . print_r( $response, true ) );
}

4. Access the entry by looping through the form fields

This example demonstrates a simple approach to accessing the field values in the entry when you don』t know the field ids.

add_action( 'gform_after_submission', 'access_entry_via_field', 10, 2 );
function access_entry_via_field( $entry, $form ) {
foreach ( $form['fields'] as $field ) {
$inputs = $field->get_entry_inputs();
if ( is_array( $inputs ) ) {
foreach ( $inputs as $input ) {
$value = rgar( $entry, (string) $input['id'] );
// do something with the value
}
} else {
$value = rgar( $entry, (string) $field->id );
// do something with the value
}
}
}

5. Create a ticket in WSDesk

See the How to use WSDesk create ticket API with third-party forms and plugins? article for an example showing how to use the gform_after_submission hook to create WSDesk tickets.

See the Creating Tickets in WSDesk using the Webhooks Add-On article if you would prefer not to use custom code.

6. Submit entries to Tripleseat

See the Using the API Lead Form with Gravity Forms in WordPress article by Tripleseat for an example showing how to use the gform_after_submission hook.

7. Submit entries to SharpSpring

See the Integrating Gravity Forms article by SharpSpring for an example showing how to use the gform_after_submission hook, they also have a tool for generating the code snippet for your form.

8. Create an Events Calendar plugin event

This example demonstrates how the gform_after_submission hook and the tribe_create_event function can be used to create an event in the Events Calendar plugin.

add_action( 'gform_after_submission', function ( $entry ) {
if ( ! function_exists( 'tribe_create_event' ) ) {
return;
}

$start_date = rgar( $entry, '4' );
$start_time = rgar( $entry, '5' );
$end_date = rgar( $entry, '6' );
$end_time = rgar( $entry, '7' );

$args = array(
'post_title' => rgar( $entry, '1' ),
'post_content' => rgar( $entry, '2' ),
'EventAllDay' => (bool) rgar( $entry, '3.1' ),
'EventHideFromUpcoming' => (bool) rgar( $entry, '3.2' ),
'EventShowInCalendar' => (bool) rgar( $entry, '3.3' ),
'feature_event' => (bool) rgar( $entry, '3.4' ),
'EventStartDate' => $start_date,
'EventStartTime' => $start_time ? Tribe__Date_Utils::reformat( $start_time, 'H:i:s' ) : null,
'EventEndDate' => $end_date,
'EventEndTime' => $end_time ? Tribe__Date_Utils::reformat( $end_time, 'H:i:s' ) : null,
);

GFCommon::log_debug( 'gform_after_submission: tribe_create_event args => ' . print_r( $args, 1 ) );
$event_id = tribe_create_event( $args );
GFCommon::log_debug( 'gform_after_submission: tribe_create_event result => ' . var_export( $event_id, 1 ) );
} );

9. Check entry spam status

This example shows how you can check if the entry has been marked as spam and prevent the rest of your function from running.

add_action( 'gform_after_submission', 'action_gform_after_submission_spam_check', 10, 2 );
function action_gform_after_submission_spam_check( $entry, $form ) {
if ( rgar( $entry, 'status' ) === 'spam' ) {
return;
}

// The code that you want to run for submissions which aren't spam.
}

Placement

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

Source Code

This action hook is located in GFFormDisplay::process_form() in form_display.php.

gform_after_update_entry

gform_after_update_entry

DescriptionUsageParametersExamples1. Update entry properties.2. Log the entry before and after update.3. Trigger Zapier Feed4. Trigger Mailchimp Feed5. Trigger Webhooks Feed6. Add notePlacementSource Code

Description
This hook fires after the entry has been updated via the entry detail page.
Usage
The following would run for any form:
1add_action( 'gform_after_update_entry', 'your_function_name', 10, 2 );
To target a specific form append the form id to the hook name. (format: gform_after_update_entry_FORMID)
1add_action( 'gform_after_update_entry_10', 'your_function_name', 10, 2 );

Parameters

$form Form Object
The form object for the entry.

$entry_id integer
The entry ID.

$original_entry Entry Object
The entry before being updated. Since 1.9.12.9.

Examples
1. Update entry properties.
This example sets the entry as unread and stars it.
12345add_action( 'gform_after_update_entry', 'update_entry', 10, 2 );function update_entry( $form, $entry_id ) {    GFAPI::update_entry_property( $entry_id, 'is_read', 0 );    GFAPI::update_entry_property( $entry_id, 'is_starred', 1 );}
2. Log the entry before and after update.
123456add_action( 'gform_after_update_entry', 'log_post_update_entry', 10, 3 );function log_post_update_entry( $form, $entry_id, $original_entry ) {    $entry = GFAPI::get_entry( $entry_id );    GFCommon::log_debug( 'gform_after_update_entry: original_entry => ' . print_r( $original_entry, 1 ) );    GFCommon::log_debug( 'gform_after_update_entry: updated entry => ' . print_r( $entry, 1 ) );}
3. Trigger Zapier Feed
This example shows how you can send the updated entry to Zapier.
123456789add_action( 'gform_after_update_entry', 'send_to_zapier_on_update', 10, 2 );function send_to_zapier_on_update( $form, $entry_id ) {    $entry = GFAPI::get_entry( $entry_id );    if ( class_exists( 'GFZapier' ) ) {        GFZapier::send_form_data_to_zapier( $entry, $form );    } elseif ( function_exists( 'gf_zapier' ) ) {        gf_zapier()->maybe_process_feed( $entry, $form );    }}
4. Trigger Mailchimp Feed
This example shows how you can send the updated entry to Mailchimp.
1234567add_action( 'gform_after_update_entry', 'send_to_mailchimp_on_update', 10, 2 );function send_to_mailchimp_on_update( $form, $entry_id ) {    if ( function_exists( 'gf_mailchimp' ) ) {        $entry = GFAPI::get_entry( $entry_id );        gf_mailchimp()->maybe_process_feed( $entry, $form );    }}
You can use this same snippet for other similar add-ons like Zoho CRM, AgileCRM, ActiveCampaign, etc… Replacing gf_mailchimp above by the corresponding add-on function name, like gf_zohocrm, gf_agilecrm, gf_activecampaign, etc…
5. Trigger Webhooks Feed
This example shows how you can trigger processing of Webhooks feeds which use the background (async) processing feature.
1234567add_action( 'gform_after_update_entry', function ( $form, $entry_id ) {    if ( function_exists( 'gf_webhooks' ) ) {        $entry = GFAPI::get_entry( $entry_id );        gf_webhooks()->maybe_process_feed( $entry, $form );        gf_feed_processor()->save()->dispatch();    }}, 10, 2 );
6. Add note
This example shows how you can add a note to the entry.
1234add_action( 'gform_after_update_entry', function ( $form, $entry_id ) {    $current_user = wp_get_current_user();    RGFormsModel::add_note( $entry_id, $current_user->ID, $current_user->display_name, 'the note to be added' );}, 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFEntryDetail::lead_detail_page() in entry_detail.php.

gform_{$SHORT_SLUG}_field_value

gform_{$SHORT_SLUG}_field_value

DescriptionShort Slug ValuesUsageParametersExamples1. ActiveCampaign – Use Choice Text Instead of Value2. ActiveCampaign – Replace Commas with Pipes3. Emma – Format Checkbox Field4. Help Scout – Change Value of Specific Field5. Zoho CRM – Format Date Field6. Zoho CRM – Format Checkbox FieldPlacementSinceSource Code

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 any add-on you can use gform_addon_field_value.
Short Slug Values
The Gravity Forms Add-On Slugs article lists the available short slugs to use with this hook:
The following add-ons listed in the slug article do not use the hook:

Gravity Forms CLI Add-On
Gravity Forms Debug Add-On
Gravity Forms Gutenberg Add-On

The Zapier Add-On implements its own version of the hook:

gform_zapier_field_value

Usage
The base filter which would run for all forms and all fields would be used like so:
1add_filter( 'gform_helpscout_field_value', 'your_function_name', 10, 4 );
To target a specific form append the form id to the hook name. (format: gform_{$SHORT_SLUG}_field_value_FORMID)
1add_filter( 'gform_helpscout_field_value_10', 'your_function_name', 10, 4 );
To target a specific field append both the form id and the field id to the hook name. (format: gform_{$SHORT_SLUG}_field_value_FORMID_FIELDID)
1add_filter( 'gform_helpscout_field_value_10_3', 'your_function_name', 10, 4 );

Parameters

$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.

Examples
1. ActiveCampaign – 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.
1234567891011add_filter( 'gform_activecampaign_field_value', 'gf_get_choice_text', 10, 4 );function gf_get_choice_text( $value, $form, $entry, $field_id ) {    gf_activecampaign()->log_debug( __METHOD__ . '(): running.' );    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && $field->type == 'survey' ) {        $value = $field->get_value_export( $entry, $field_id, true );        gf_activecampaign()->log_debug( __METHOD__ . '(): Value: ' . $value );    }    return $value;}
2. ActiveCampaign – Replace Commas with Pipes
This example shows how you can replace the commas used to separate checkbox or multi select choices with pipe characters.
123456789101112add_filter( 'gform_activecampaign_field_value', 'gf_replace_commas_with_pipes', 10, 4 );function gf_replace_commas_with_pipes( $value, $form, $entry, $field_id ) {    gf_activecampaign()->log_debug( __METHOD__ . '(): running.' );    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && ( $field->type == 'checkbox' || $field->type == 'multiselect' ) ) {        $value = str_replace( ', ', '||', $value );        gf_activecampaign()->log_debug( __METHOD__ . '(): Value: ' . $value );    }     return $value;}
3. Emma – Format Checkbox Field
This example shows how you can reformat the checkbox field value to be passed as an array instead of a string.
123456789add_filter( 'gform_emma_field_value', function ( $value, $form, $entry, $field_id ) {    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && $field->get_input_type() === 'checkbox' ) {        $value = explode( ', ', $value );    }     return $value;}, 10, 4 );
4. Help Scout – 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 Help Scout.
1234add_filter( 'gform_helpscout_field_value_10_3', function ( $value, $form, $entry, $field_id ) {     return 'your new value';}, 10, 4 );
5. Zoho CRM – Format Date Field
This example shows how you can reformat the entry date from yyyy-mm-dd to the format configured on the field.
123456789add_filter( 'gform_zohocrm_field_value', function ( $value, $form, $entry, $field_id ) {    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && $field->type == 'date' ) {        $value = GFCommon::date_display( $value, $field->dateFormat );    }     return $value;}, 10, 4 );
6. Zoho CRM – Format Checkbox Field
This example shows how you can reformat the checkbox field value to pass true or false instead of the choice. This snippet is not needed if you』re using version 1.8 of the add-on or newer.
1234567891011add_filter( 'gform_zohocrm_field_value', function ( $value, $form, $entry, $field_id ) {    gf_zohocrm()->log_debug( __METHOD__ . '(): Running...' );    $field = GFAPI::get_field( $form, $field_id );     if ( is_object( $field ) && $field->get_input_type() === 'checkbox' ) {        gf_zohocrm()->log_debug( __METHOD__ . '(): Checkbox value to true or false.' );        $value = $value ? 'true' : 'false';    }     return $value;}, 10, 4 );
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms 1.9.10.11.
Source Code
1234gf_apply_filters( "gform_{$slug}_field_value", array(    $form['id'],    $field_id), $field_value, $form, $entry, $field_id );
This filter is located in GFAddOn::maybe_override_field_value() in includes/addon/class-gf-addon.php.

gform_agilecrm_tags

gform_agilecrm_tags

DescriptionUsageParametersExamples1. Always add tags2. Add tag depending on field valuePlacementSource Code

Description
This filter is used to dynamically alter the tags to be assigned to a contact in Agile CRM.
Usage
The following would apply to all feeds:
add_filter( 'gform_agilecrm_tags', 'your_function_name', 10, 4 );

To target feeds for a specific form append the form id to the hook name. (format: gform_agilecrm_tags_FORMID)
add_filter( 'gform_agilecrm_tags_4', 'your_function_name', 10, 4 );

Parameters

$tags array
An array of tags to be assigned to the contact.

$feed Feed Object
The feed currently being processed.

$entry Entry Object
The entry currently being processed.

$form Form Object
The form currently being processed.

Examples
1. Always add tags
This example shows how you can add a new tag.
add_filter( 'gform_agilecrm_tags', 'add_new_tag', 10, 4 );
function add_new_tag( $tags, $feed, $entry, $form ) {
$tags[] = 'some tag';

return $tags;
}

2. Add tag depending on field value
This example shows how you can add a tag depending on an entry field value.
add_filter( 'gform_agilecrm_tags', 'add_new_tag', 10, 4 );
function add_new_tag( $tags, $feed, $entry, $form ) {
$product = rgar( $entry, '15' );

if ( $product != 'gravityforms' ) {
$tags[] = 'some tag';
}

return $tags;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
gf_apply_filters( 'gform_agilecrm_tags', $form['id'], $tags, $feed, $entry, $form );

This filter is located in the following methods in class-gf-agilecrm.php:

GFAgileCRM::create_contact()
GFAgileCRM::update_contact()

gform_ajax_spinner_url

gform_ajax_spinner_url

DescriptionUsageParametersExamplesChange the spinner image to a custom image file.PlacementSource Code

Description
This filter can be used to change the default AJAX spinner image
Usage
1add_filter( 'gform_ajax_spinner_url', 'custom_spinner_image', 10, 2 );
You can also specify this per form by adding the form id after the hook name.
1add_filter( 'gform_ajax_spinner_url_6', 'custom_spinner_image', 10, 2 );

Parameters

$image_src string
The spinner image URL to be filtered

$form Form Object
Current form.

Examples
Change the spinner image to a custom image file.
1234add_filter( 'gform_ajax_spinner_url', 'spinner_url', 10, 2 );function spinner_url( $image_src, $form ) {    return "http://www.somedomain.com/spinner.png";}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFFormDisplay::get_form() in form_display.php

gform_akismet_enabled

gform_akismet_enabled

DescriptionUsageParametersExamplesDisable globallyDisable for a specific form onlyUsing one function with multiple formsPlacementSource Code

Description
This filter allows default Akismet integration to be disabled globally or per form.
Usage
add_filter( 'gform_akismet_enabled', 'your_function_name', 10, 2 );

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_akismet_enabled_FORMID)
add_filter( 'gform_akismet_enabled_6', 'your_function_name', 10, 2 );

Parameters

$is_enabled bool
Defaults to true; return false to disable Akismet.

$form_id int
The ID of the form being processed. Since 2.4.18.5.

Examples
Disable globally
This example will globally disable Akismet integration with Gravity Forms:
add_filter( 'gform_akismet_enabled', '__return_false' );

Disable for a specific form only
This example will disable Akismet integration with Gravity Forms only for form id 1:
add_filter( 'gform_akismet_enabled_1', '__return_false' );

Using one function with multiple forms
add_filter( 'gform_akismet_enabled', function( $is_enabled, $form_id ) {
if ( in_array( $form_id, array( 1, 3, 5 ) ) ) {
$is_enabled = false;
}

return $is_enabled;
}, 10, 2 );

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::akismet_enabled() in common.php.

gform_akismet_fields

gform_akismet_fields

DescriptionUsageParametersExamples1. Override the comment_content2. Provide the IP addressPlacementSource Code

Description
Use this filter to specify the fields that are sent to the Akismet anti-spam service.
Usage
add_filter( 'gform_akismet_fields', 'set_akismet_fields', 10, 4 );

You can also target a specific form by adding the form id after the hook name.
add_filter( 'gform_akismet_fields_6', 'set_akismet_fields', 10, 4 );

Parameters

$akismet_fields array
The data to be sent to Akismet, in the following format:
array(
'comment_type' => 'gravity_form',
'comment_author' => 'Author name',
'comment_author_email' => '[email protected]',
'comment_author_url' => 'http://www.someurl.com',
'comment_content' => 'Some text',
'contact_form_subject' => 'Contact Us',
'comment_author_ip' => '127.0.0.1',
'permalink' => 'http://www.someurl.com/contactus',
'user_ip' => '127.0.0.1',
'user_agent' => 'user agent string',
'referrer' => 'http://www.referrer.com',
'blog' => 'http://www.someurl.com',
);

Property
Default Source

comment_author
The first Name type field found on the form

comment_author_email
The first Email type field found on the form

comment_author_url
The first Website type field found on the form

comment_content
The first Paragraph type field found on the form

contact_form_subject
The form title

$form Form Object
The form which created the entry.

$entry Entry Object
The entry being processed.

$action string
The action triggering the Akismet request: submit, spam, or ham. Since version 2.4.18.5.

Examples
1. Override the comment_content
This example overrides the value in the 「comment_content」 Akismet field so that is is pulled from another field. (field ID: 1).
add_filter( 'gform_akismet_fields', 'set_akismet_fields', 10, 3 );
function set_akismet_fields( $akismet_fields, $form, $entry ) {
$akismet_fields['comment_content'] = rgar( $entry, '1' );

return $akismet_fields;
}

2. Provide the IP address
This example shows how you can pass the IP address to Akismet when it has been removed from the entry using the gform_ip_address filter.
add_filter( 'gform_akismet_fields', 'set_akismet_fields', 10, 3 );
function set_akismet_fields( $akismet_fields, $form, $entry ) {
remove_filter( 'gform_ip_address', '__return_empty_string' );
$ip = GFFormsModel::get_ip();
$akismet_fields['comment_author_IP'] = $ip;
$akismet_fields['user_ip'] = preg_replace( '/[^0-9., ]/', '', $ip );

return $akismet_fields;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::get_akismet_fields() in common.php.

gform_allowable_tags

gform_allowable_tags

IntroductionUsageParametersExamples1. Return a string containing HTML tags2. Return true3. Return falsePlacementSource Code

Introduction
During form submission when the field values are being saved the values are sanitized to prevent potentially dangerous content such as scripts from being saved to the database.
The gform_allowable_tags filter can be used to control the usage of the PHP strip_tags() and the WordPress wp_kses_post() functions when sanitizing the submitted field values.
Usage
The base filter which would run for all forms and fields can be used like so:
add_filter( 'gform_allowable_tags', 'your_function_name', 10, 3 );

You can limit the scope of the filter to a single form by appending the form id on the end of the hook name like so:
add_filter( 'gform_allowable_tags_6', 'your_function_name', 10, 3 );

Parameters

$allowable_tags string | boolean
Default value is always false. See examples below for details.

$field Field Object
The field currently being processed.

$form_id integer
The ID of the current form.

Examples
1. Return a string containing HTML tags
When you return a string containing specific HTML tags the field value will first be passed through the WordPress wp_kses_post() function which will sanitize the value leaving only the HTML tags WordPress permits in post content. The value will then be passsed through the PHP strip_tags() function which will remove all remaining tags execpt those you have specified.
add_filter( 'gform_allowable_tags_6', 'allow_basic_tags' );
function allow_basic_tags( $allowable_tags ) {
return '

';
}

2. Return true
When you return true the field value will be passed through the WordPress wp_kses_post() function which will sanitize the value leaving only the HTML tags WordPress permits in post content.
add_filter( 'gform_allowable_tags_6', '__return_true' );

3. Return false
When you return false the field value will be saved without being sanitized. Please note, the value may still be sanitized before it is displayed in the admin or when merge tags are processed to prevent potentially dangerous scripts from running.
add_filter( 'gform_allowable_tags_6', '__return_false' );

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GF_Field::get_allowable_tags() in includes/fields/class-gf-field.php.

gform_append_field_choice_option

gform_append_field_choice_option

DescriptionUsageParametersExampleSource Code

Description
This filter can be used to add custom options for each choice.
Usage
1234gform.addFilter('gform_append_field_choice_option', function (str, field, i) {    // define the markup for your custom option    return str;});

Parameters

str string
An empty string, to be replaced with your custom markup.

field array
The current field object.

i integer
The index of the current choice.

Example
This example adds a new option to the choice setting called custom.
It uses the gform_editor_js action to load the code snippet on the form editor page.
123456789101112131415161718192021add_action( 'gform_editor_js', 'custom_option_editor_script' );function custom_option_editor_script() {    ?>