gform_chainedselects_column_unique_values_limit

gform_chainedselects_column_unique_values_limit

DescriptionUsageParametersExamplesPlacementSource Code

Description
The 「gform_chainedselects_column_unique_values_limit」 filter limits the number of unique values allowed for each column.
Usage
add_filter( 'gform_chainedselects_column_unique_values_limit', 'your_function_name' );

Parameters

$limit int
The limit of unique values allowed for each column.

Examples
add_filter( 'gform_chainedselects_column_unique_values_limit', 'set_limit' );
function set_limit( $limit ) {
return 100;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GF_Chained_Field_Select::is_choice_limit_exceeded() in gravityformschainedselects/class-gf-chainedselects.php.

gform_chained_selects_input_choices

gform_chained_selects_input_choices

DescriptionUsageParametersExamples1. Populate Year, Make, and Model2. Define the default choicePlacementSource CodeSince

Description
The filter gform_chained_selects_input_choices is used to modify the choices that will appear in each drop down of a Chained Select field.

IMPORTANT: For obvious reasons, this filter can』t run when the page where your form is embedded is cached. This is not a Gravity Forms limitation but a consequence of using caching.

Usage
Filter all chained selects for all forms.
1add_action( 'gform_chained_selects_input_choices', 'your_function_name' );
Filter all chained selects for a specific form.
1add_action( 'gform_chained_selects_input_choices_6', 'your_function_name' );
Filter chained selects for a specific form and specific field.
1add_action( 'gform_chained_selects_input_choices_6_2', 'your_function_name' );
Filter a specific chained select for a specific form and field.
1add_action( 'gform_chained_selects_input_choices_6_2_1', 'your_function_name' );

Parameters

$input_choices array
An array of Choices that will be used to populate the current drop down.

$form_id integer
The form ID for the current form.

$field Field Object
The current field object.

$input_id float
The input ID of the current input (i.e. drop down) being processed. Example: 3.1.

$full_chain_value array
An array of values representing the selected value for each input in the chain of selects. Example:
12345array(    '3.1' => 'Toyota',    '3.2' => 'Matrix',    '3.3' => 2013);

$value string
The value of the current chained select.

$index int – Added in version 1.1.
The index of the specific chained select.

Examples
1. Populate Year, Make, and Model
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384// populates the "Make" drop down of our Chained Selectadd_filter( 'gform_chained_selects_input_choices_855_14_1', 'gf_populate_makes', 10, 7 );function gf_populate_makes( $input_choices, $form_id, $field, $input_id, $chain_value, $value, $index ) {     $api_key = '9du7r286jng2zjjaf8antxur'; // signup for your own Edmunds API key here: http://edmunds.mashery.com/member/register    $choices = array();     $response = wp_remote_get( "https://api.edmunds.com/api/vehicle/v2/makes?state=new&year=" . date( 'Y' ) . "&view=basic&fmt=json&api_key={$api_key}" );    if ( wp_remote_retrieve_response_code( $response ) != 200 ) {        return $input_choices;    }     $makes = json_decode( wp_remote_retrieve_body( $response ) )->makes;    foreach( $makes as $make ) {        $choices[] = array(            'text'       => $make->name,            'value'      => $make->niceName,            'isSelected' => false        );    }     return $choices;} // populates the "Model" drop down of our Chained Selectadd_filter( 'gform_chained_selects_input_choices_855_14_2', 'gf_populate_models', 10, 7 );function gf_populate_models( $input_choices, $form_id, $field, $input_id, $chain_value, $value, $index ) {     $api_key = '9du7r286jng2zjjaf8antxur'; // signup for your own Edmunds API key here: http://edmunds.mashery.com/member/register    $choices = array();     $selected_make = $chain_value[ "{$field->id}.1" ];    if( ! $selected_make ) {        return $input_choices;    }     $response = wp_remote_get( "https://api.edmunds.com/api/vehicle/v2/{$selected_make}/models?view=basic&fmt=json&api_key={$api_key}" );    if ( wp_remote_retrieve_response_code( $response ) != 200 ) {        return $input_choices;    }     $models = json_decode( wp_remote_retrieve_body( $response ) )->models;    foreach( $models as $model ) {        $choices[] = array(            'text'       => $model->name,            'value'      => $model->niceName,            'isSelected' => false        );    }     return $choices;} // populates the "Year" drop down of our Chained Selectadd_filter( 'gform_chained_selects_input_choices_855_14_3', 'gf_populate_years', 10, 7 );function gf_populate_years( $input_choices, $form_id, $field, $input_id, $chain_value, $value, $index ) {     $api_key = '9du7r286jng2zjjaf8antxur'; // signup for your own Edmunds API key here: http://edmunds.mashery.com/member/register    $choices = array();     $selected_make  = $chain_value[ "{$field->id}.1" ];    $selected_model = $chain_value[ "{$field->id}.2" ];    if( ! $selected_make || ! $selected_model ) {        return $input_choices;    }     $response = wp_remote_get( "https://api.edmunds.com/api/vehicle/v2/{$selected_make}/{$selected_model}/years/count?view=full&fmt=json&api_key={$api_key}" );    if ( wp_remote_retrieve_response_code( $response ) != 200 ) {        return $input_choices;    }     $years = wp_list_pluck( json_decode( wp_remote_retrieve_body( $response ) )->years, 'year' );    rsort( $years );     foreach( $years as $year ) {        $choices[] = array(            'text'       => $year,            'value'      => $year,            'isSelected' => false        );    }     return $choices;}
2. Define the default choice
The following example shows how you can define which choice in the drop down should be selected by default. In this case we are setting the second choice as the default choice in the third drop down of field 1 on form 123.
1234add_filter( 'gform_chained_selects_input_choices_123_1_3', function( $choices ) {    $choices[1]['isSelected'] = true;    return $choices;} );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
1$input_choices = gf_apply_filters( 'gform_chained_selects_input_choices', array( $this->formId, $this->id, $index ), $input_choices, $this->formId, $this, $input_id, $full_chain_value, $value, $index );
This hook is located in GF_Chained_Field_Select::get_input_choices() in class-gf-field-chained-select.php.
Since

The form specific version of this hook was added in Gravity Forms Chained Selects 1.0.
The $index parameter was added in version 1.1.

gform_cdata_open

gform_cdata_open

DescriptionUsageParametersExamplesSource CodeSince

Description

These filters provide the ability to validate your forms with XHTML doctypes by allowing you to wrap the javascript output with the form in CDATA blocks.

Be aware. Using this function in conjunction with advanced form javascript will cause issues due to an issue with how WordPress handles CDATA tags.

Usage

add_filter( 'gform_cdata_open', 'my_cdata_open' );
add_filter( 'gform_cdata_close', 'my_cdata_close' );

Parameters

$cdata_string string
Empty by default. Return an opening or closing CDATA block respectively.

Examples

This example demonstrates how to wrap your form javascript in CDATA blocks.

add_filter( 'gform_cdata_open', 'my_cdata_open' );
function my_cdata_open() {
return '';
}
add_filter( 'gform_cdata_close', 'my_cdata_close' );
function my_cdata_close() {
return '';
}

Source Code

As of Gravity Forms 2.5.8, this filter is located in GFCommon::get_inline_script_tag() in common.php.

This filter was previously located in the following methods:

GFFormDisplay::get_form() in form_display.phpGFFormDisplay::footer_init_scripts() in form_display.phpGFFormDisplay::get_js_redirect_confirmation() in form_display.phpGFFormDisplay::get_form_init_scripts() in form_display.phpGF_Field_CAPTCHA::get_field_input() in includes/fields/class-gf-field-captcha.php

Since

Version 1.6.3

gform_card_security_code

gform_card_security_code

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the credit card field and can be used to modify the 「Security Code」 label.
Usage
add_filter( 'gform_card_security_code', 'change_security_code', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default Security Code label:
add_filter( 'gform_card_security_code', 'change_security_code', 10, 2 );
function change_security_code( $label, $form_id ) {
return "Security Code";
}

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_CreditCard::get_field_input() in includes/fields/class-gf-field-creditcard.php.

gform_card_number

gform_card_number

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the credit card field and can be used to modify the 「Card Number」 label.
Usage
add_filter( 'gform_card_number', 'change_number', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default Card Number label:
add_filter( 'gform_card_number', 'change_number', 10, 2 );
function change_number( $label, $form_id ) {
return "Number";
}

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_CreditCard::get_field_input() in includes/fields/class-gf-field-creditcard.php.

gform_card_name

gform_card_name

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the credit card field and can be used to modify the 「Cardholder Name」 label.
Usage
add_filter( 'gform_card_name', 'change_name', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default Cardholder Name label:
add_filter( 'gform_card_name', 'change_name', 10, 2 );
function change_name( $label, $form_id ) {
return "Name on card";
}

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_CreditCard::get_field_input() in includes/fields/class-gf-field-creditcard.php.

gform_card_expiration

gform_card_expiration

DescriptionUsageParametersExamplesPlacementSource Code

Description
This filter is executed when creating the credit card field and can be used to modify the 「Expiration Date」 label.
Usage
add_filter( 'gform_card_expiration', 'change_expiration', 10, 2 );

Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default Expiration Date label:
add_filter( 'gform_card_expiration', 'change_expiration', 10, 2 );
function change_expiration( $label, $form_id ) {
return "Expires";
}

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_CreditCard::get_field_input() in includes/fields/class-gf-field-creditcard.php.

gform_card_details

gform_card_details

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
This filter is executed when creating the Stripe Card or Square field and can be used to modify the 「Card Details」 label.
Usage
1add_filter( 'gform_card_details', 'change_details', 10, 2 );
Parameters

$label string
The label to be filtered.

$form_id integer
The current form』s id.

Examples
This example changes the default Card Details label:
1234add_filter( 'gform_card_details', 'change_details', 10, 2 );function change_details( $label, $form_id ) {    return "Credit Card Specifics";}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Stripe 2.6 and Square 1.0.
Source Code
Stripe add-on: This filter is located in GF_Field_Stripe_CreditCard::get_form_editor_inline_script_on_page_render() in gravityformsstripe/includes/class-gf-field-stripe-creditcard.php
Square add-on: This filter is located in GF_Field_Square_CreditCard::get_form_editor_inline_script_on_page_render() in gravityformssquare/includes/class-gf-field-square-creditcard.php

gform_capsulecrm_task

gform_capsulecrm_task

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
This filter allows the Capsule CRM Task object to be modified before it is created.
Usage
The following would apply to all forms:
1add_filter( 'gform_capsulecrm_task', 'your_function_name', 10, 4 );
To target a specific form, append the form id to the hook name. (format: gform_capsulecrm_task_FORMID)
1add_filter( 'gform_capsulecrm_task_1', 'your_function_name', 10, 4 );
To target a specific feed for a form, append the form id and feed id to the hook name. (format: gform_capsulecrm_task_FORMID_FEEDID)
1add_filter( 'gform_capsulecrm_task_1_7', 'your_function_name', 10, 4 );

Parameters

$task array
Capsule CRM task.
12345678910111213141516array (  'description' => 'Capsule CRM',  'detail' => 'Task Created by API',  'lastName' => 'TestLast',  'dueOn' => '2019-02-14',  'dueTime => '21:25:08',  'status' => 'OPEN',  'category' =>       array(        'name' => 'Follow-up'      ),   'owner' =>      array(       'username' => 'testuser'     ))

$form Form Object
The current form.

$entry Entry Object
The current entry.

$feed Feed Object
The current feed.

Examples
12345add_filter( 'gform_capsulecrm_task', 'change_task_object', 10, 4 );function change_task_object( $task, $form, $entry, $feed ){    $task['description'] = 'Task Created by API';    return $task;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms Capsule CRM Add-On version 1.2.
Source Code
This filter is located in GFCapsuleCRM::create_task() in class-gf-capsulecrm.php.

gform_capsulecrm_person

gform_capsulecrm_person

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
This filter allows the Capsule CRM Person object to be modified before it is created/updated.
Usage
The following would apply to all forms:
1add_filter( 'gform_capsulecrm_person', 'your_function_name', 10, 4 );
To target a specific form, append the form id to the hook name. (format: gform_capsulecrm_person_FORMID)
1add_filter( 'gform_capsulecrm_person_1', 'your_function_name', 10, 4 );
To target a specific feed for a form, append the form id and feed id to the hook name. (format: gform_capsulecrm_person_FORMID_FEEDID)
1add_filter( 'gform_capsulecrm_person_1_7', 'your_function_name', 10, 4 );

Parameters

$person array
Capsule CRM person.
12345678910111213array (  'type' => 'person',  'firstName' => 'TestFirst',  'lastName' => 'TestLast',  'about' => "New Person created by API',  'jobTitle => '',  'emailAddress' =>     array (      array(        'address' => '[email protected]'      )    ))

$form Form Object
The current form.

$entry Entry Object
The current entry.

$feed Feed Object
The current feed.

Examples
12345add_filter( 'gform_capsulecrm_person', 'change_person_object', 10, 4 );function change_person_object( $person, $form, $entry, $feed ){    $person['about'] = 'Person Created by API';    return $person;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms Capsule CRM Add-On version 1.2.
Source Code
This filter is located in GFCapsuleCRM::create_person() in class-gf-capsulecrm.php.