gform_authorizenet_amount_pre_authorize

gform_authorizenet_amount_pre_authorize

DescriptionUsageParametersExamplePlacementSource Code

Description
This filter can be used to modify the authorization amount before it is sent to Authorize.net.
Usage
The filter which would run for all 『product and services』 type Authorize.net feeds can be used like so:
1add_filter( 'gform_authorizenet_amount_pre_authorize', 'your_function_name', 10, 6 );

Parameters

$auth_amount float
The authorization amount. Defaults to value of $config[『amount』].

$transaction object
The Authorize.net transaction object.

$form_data Form Data
An associative array containing the form title, billing address, payment amount, setup fee amount, line items created using the submitted pricing field values and any discounts from coupons.

$config Authorize Net Config
The feed which is currently being processed.

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

$entry Entry Object
The entry which is currently being processed. Since version 2.1.8.

Example
The following example shows how you can override the authorization amount.
12345678add_filter( 'gform_authorizenet_amount_pre_authorize', 'change_amount', 10, 4 );function change_amount( $auth_amount, $transaction, $form_data, $config, $form ) {    if ( $form['id'] == 10 ) {        $auth_amount = 1;    }     return $auth_amount;}
Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFAuthorizeNet::authorize() in class-gf-authorizenet.php.

gform_author_dropdown_args

gform_author_dropdown_args

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when the form editor is loaded, when creating the author drop down selection for the Post Fields. Use this hook to change the list of authors displayed in the drop down by filtering the $args parameter to be passed to the wp_dropdown_users( $args ) function.
Usage
Applies to all forms:
1add_filter( 'gform_author_dropdown_args', 'set_users' );
Applies to a specific form. In this case, form Id 5:
1add_filter( 'gform_author_dropdown_args_5', 'set_users' );
Parameters

$args array
The args to be filtered, in the format expected by the wp_dropdown_users() WordPress function.

Examples
This example changes the author drop down so that it includes two users (Ids 1 and 8):
12345add_filter( 'gform_author_dropdown_args', 'set_users' );function set_users( $args ) {    $args['include'] = '1,8';    return $args;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in form_detail.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() {    ?>        

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_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_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_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_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()