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_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_aweber_ad_tracking

gform_aweber_ad_tracking

DescriptionUsageParametersExamplePlacementSource Code

Description
This filter can be used to modify the ad_tracking parameter value before it is sent to AWeber.
Usage
The filter which would run for all AWeber feeds can be used like so:
add_filter( 'gform_aweber_ad_tracking', 'your_function_name', 10, 4 );

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_aweber_ad_tracking_5', 'your_function_name', 10, 4 );

Parameters

$ad_tracking string
The default value of the ad_tracking parameter is the form title.

$form Form Object
The Form which is currently being processed.

$entry Entry Object
The Entry which is currently being processed.

$feed Feed Object
The Feed which is currently being processed.

Example
The following example shows how you can change the parameter value.
add_filter( 'gform_aweber_ad_tracking', function ( $ad_tracking, $form, $entry, $feed ) {

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

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
apply_filters( "gform_aweber_ad_tracking_{$form['id']}", apply_filters( 'gform_aweber_ad_tracking', $form['title'], $entry, $form, $feed ), $entry, $form, $feed )

This filter is located in GFAWeber::export_feed() in class-gf-aweber.php.

gform_authorizenet_transaction_pre_authorize

gform_authorizenet_transaction_pre_authorize

DescriptionUsageParametersExamplesPlacementSource Code

Description
Allows the transaction to be modified before authorization occurs.
Usage
add_filter( 'gform_authorizenet_transaction_pre_authorize', 'your_function_name', 10, 4 );

Parameters

$original_transaction AuthorizeNetAIM Object
The payment transaction.

$form_data array
Form information needed for billing.

$config array
Configuration information including feed setup with billing information.

$form Form Object
The current form object.

Examples
add_filter( 'gform_authorizenet_transaction_pre_authorize', 'change_authorization', 10, 4 );
function change_authorization( $original_transaction, $form_data, $config, $form ){
return $original_transaction;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFAuthorizeNet::authorize() in gravityformsauthorizenet/class-gf-authorizenet.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() {    ?>