gform_currency_disabled

gform_currency_disabled

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to enable/disable the currency drop down on the settings page.
Usage
add_filter( 'gform_currency_disabled', '__return_false' );

Parameters

$is_disabled string
Value to be filtered. Use 「true」 to disable the currency drop down. Use 「false」 to enable it.

Examples
This example disables the currency drop down.
add_filter( 'gform_currency_disabled', '__return_false' );

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

gform_creditcard_types

gform_creditcard_types

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to change the default list of supported credit card types.
Usage
1add_filter( 'gform_creditcard_types', 'add_card_type' );
Parameters

$cards array
The card array to be filtered. It is defined as follows:
123456789101112131415161718192021222324252627282930313233343536373839404142434445$cards =array (    array (        'name' => 'American Express',        'slug' => 'amex',        'lengths' => '15',        'prefixes' => '34,37',        'checksum' => true    ),    array (        'name' => 'Discover',        'slug' => 'discover',        'lengths' => '16',        'prefixes' => '6011,622,64,65',        'checksum' => true    ),    array (        'name' => 'MasterCard',        'slug' => 'mastercard',        'lengths' => '16',        'prefixes' => '51,52,53,54,55',        'checksum' => true    ),    array (        'name' => 'Visa',        'slug' => 'visa',        'lengths' => '13,16',        'prefixes' => '4,417500,4917,4913,4508,4844',        'checksum' => true    ),    array (        'name' => 'JCB',        'slug' => 'jcb',        'lengths' => '16',        'prefixes' => '35',        'checksum' => true    ),    array (        'name' => 'Maestro',        'slug' => 'maestro',        'lengths' => '12,13,14,15,16,18,19',        'prefixes' => '5018,5020,5038,6304,6759,6761',        'checksum' => true    ));
Note: The lengths, prefixes and checksum properties are used for validation and card type detection. Lengths indicates the card number』s allowed number of digits, prefixes indicates the allowed starting digit sequence and checksum indicates if the card validation requires a checksum.

Examples
This example removes Maestro from the list of available credit cards.
12345add_filter( 'gform_creditcard_types', 'remove_maestro' );function remove_maestro( $cards ) {    unset( $cards[5] ); //removing Maestro from the list    return $cards;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::get_card_types() in common.php.

gform_coupons_post_delete_coupon

gform_coupons_post_delete_coupon

DescriptionUsageParametersPlacementSinceSource Code

Description
This JavaScript action fires after a coupon is deleted from a field, allowing further actions to be performed.
Usage
123gform.addAction( 'gform_coupons_post_delete_coupon', function ( code, formId ) {    // do stuff} );

Parameters

code string
The coupon code which was deleted.

formId int
The ID of the current form.

Placement
Your code snippet can be placed in a HTML field on your form or in a theme custom JavaScript file.
Since
This action was added in Gravity Forms Coupons Add-On version 2.9.
Source Code
This hook is located in DeleteCoupon() in gravityformscoupons/js/coupons.js.

gform_coupons_is_valid_code

gform_coupons_is_valid_code

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
Overrides coupon code alphanumeric checking.
Usage
add_filter( 'gform_coupons_is_valid_code', 'your_function_name', 10, 2 );

Parameters

$is_alphanumeric bool
If the coupon code is alphanumeric.

$field Field Object
The field object.

Examples
add_filter( 'gform_coupons_is_valid_code', 'mark_coupon_valid', 10, 2 );
function mark_coupon_valid( $alphanumeric, $field ){
return true;
}

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms Coupons Add-On version 2.4.
Source Code
This filter is located in GFCoupons::check_if_duplicate_coupon_code() in gravityformscoupons/class-gf-coupons.php.

gform_coupons_discount_amount

gform_coupons_discount_amount

DescriptionUsageJavaScript VersionParametersExamplePlacementSource CodePHP VersionParametersExamplePlacementSource CodeVersion

Description
This filter can be used to modify the coupon discount before it is applied to the form total.
Usage
The gform_coupons_discount_amount filter has both a JavaScript version and a PHP version. Both versions should be used.
The JavaScript version only modifies the coupon discount on the front-end.
gform.addFilter( 'gform_coupons_discount_amount', function( discount, couponType, couponAmount, price, totalDiscount ) {
// do stuff

return discount;
} );

The PHP version modifies the coupon discount during submission, ensuring that the pricing data used to create the entry and used with payment add-ons is updated.
add_filter( 'gform_coupons_discount_amount', function( $discount, $coupon, $price, $entry ) {
// do stuff

return $discount;
}, 10, 4 );

JavaScript Version

Parameters

discount float
The discount amount.

couponType float
The couponAmountType from the Coupons Feed Meta.

couponAmount float
The discount amount from the Coupons Feed Meta.

price float
The form total excluding discounts.

totalDiscount float
The total discount from all currently applied coupons.

Example
This example shows how you can adjust the coupon discount for logged-in users.
gform.addFilter( 'gform_coupons_discount_amount', function( discount, couponType, couponAmount, price, totalDiscount ) {
// you would need to write your own JS-version of is_user_logged_in()
if ( is_user_logged_in() ) {
discount += 5;
}
return discount;
} );

Placement
Your code snippet can be placed in a HTML field on your form or in a theme custom JavaScript file.
Source Code
This filter is located in GetDiscount() in js/coupons.js.
PHP Version

Parameters

$discount float
The discount amount.

$coupon array
Contains the coupon meta which is copied from the Coupons Feed Meta.
array(
'amount' => 100,
'name' => 'test100',
'type' => 'percentage',
'code' => 'TEST100',
'can_stack' => false,
'usage_count' => 2,
);

$price float
The form total excluding discounts.

$entry Entry Object
The current entry.

Example
This example shows how you can adjust the coupon discount for logged-in users.
add_filter( 'gform_coupons_discount_amount', 'add_logged_in_user_bonus_discount', 10, 4 );
function add_logged_in_user_bonus_discount( $discount, $coupon, $price, $entry ) {
if ( is_user_logged_in() ) {
$discount += 5;
}

return $discount;
}

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCoupons::get_discount() in class-gf-coupons.php.
Version
The $entry parameter was added to the PHP version of the hook in Coupons version 2.6.3.

gform_coupons_can_apply_coupon

gform_coupons_can_apply_coupon

DescriptionUsageParametersExamplesRestrict a coupon to a single formLimit a coupon to logged in users onlyPlacementSinceSource Code

Description
This PHP filter allows custom logic to be used to determine if the coupon code can be applied.
Usage
apply_filters( 'gform_coupons_can_apply_coupon', $can_apply, $coupon_code, $existing_coupon_codes, $feed, $form );

Parameters

$can_apply array
The coupon validation result.

$coupon_code string
The coupon code being validated.

$existing_coupon_codes string
The coupon codes which have already been applied.

$feed Feed Object
The feed (configuration) for the coupon code being validated.

$form Form Object
The current form.

Examples
Restrict a coupon to a single form
The following example restricts the usage of a coupon code to a form with id 1.
add_filter( 'gform_coupons_can_apply_coupon', function ( $can_apply, $coupon_code, $existing_coupon_codes, $feed, $form ) {
if ( $form['id'] == 1 && $coupon_code !== 'FREE' ) {
$can_apply['is_valid'] = false;
$can_apply['invalid_reason'] = 'the error message';
}

return $can_apply;
}, 10, 5 );

Limit a coupon to logged in users only
The following example restricts the usage of a coupon code only to logged in users.
add_filter( 'gform_coupons_can_apply_coupon', function ( $can_apply, $coupon_code, $existing_coupon_codes, $feed, $form ) {
if ( is_user_logged_in() === false && $coupon_code === 'TEST' ) {
$can_apply['is_valid'] = false;
$can_apply['invalid_reason'] = 'the error message';
}

return $can_apply;
}, 10, 5 );

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Coupons 2.9.
Source Code
This filter is located in apply_coupon_code() in class-gf-coupons.php.

gform_countries

gform_countries

DescriptionUsageParametersExamples1. Limit to Specific Countries2. Add New Countries3. Use Country Code as ValuePlacementSource Code

Description
This filter can be used to add or remove countries from the address field Country drop down.
Usage
1add_filter( 'gform_countries', 'your_function_name' );

Parameters

$countries array
The array to be filtered. It contains The list of countries in a standard array (see sample below).
1array( 'Argentina', 'Brazil', 'Netherlands', 'United States', 'United Kingdom', ... );

Examples
1. Limit to Specific Countries
This example demonstrates how to limit the country drop down to only a few select countries.
1234add_filter( 'gform_countries', 'remove_country' );function remove_country( $countries ){    return array( 'Brazil', 'United States', 'Netherlands', 'United Kingdom' );}
2. Add New Countries
This example demonstrates how to add new countries to the list.
12345678add_filter( 'gform_countries', function ( $countries ) {    $countries[] = 'Country 1';    $countries[] = 'Country 2';     sort( $countries );     return $countries;} );
3. Use Country Code as Value
These examples show how you can update the countries list to use the country code as the choice value.
The following example requires Gravity Forms 2.4.19.3+.
123456add_filter( 'gform_countries', function () {    $countries = GF_Fields::get( 'address' )->get_default_countries();    asort( $countries );     return $countries;} );
The following example works with Gravity Forms 1.9+.
12345678910add_filter( 'gform_countries', function ( $countries ) {    $new_countries = array();     foreach ( $countries as $country ) {        $code                   = GF_Fields::get( 'address' )->get_country_code( $country );        $new_countries[ $code ] = $country;    }     return $new_countries;} );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GF_Field_Address::get_countries() in includes/fields/class-gf-field-address.php.

gform_counter_script

gform_counter_script

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to change the initialization script for the textarea counter script. Can be used to specify different initialization parameters.
Usage
1add_filter( 'gform_counter_script', 'set_counter_script', 10, 5 );
You can also target a specific form by adding the form id after the hook name.
1add_filter( 'gform_counter_script_6', 'set_counter_script', 10, 5 );
Parameters

$script string
The script (including