gform_load_bulk_choices_choice

gform_load_bulk_choices_choice

DescriptionUsageParametersExamples1. Append custom choice propertyPlacementSinceSource Code

Description
The gform_load_bulk_choices_choice filter allows each of the current fields choices to be overridden as they are loaded into the Bulk Add Predefined Choices UI.
This filter is generally used in combination with gform_insert_bulk_choices_choice, and is useful for generating unique text patterns for adding arbitrary data to a choice.
Usage
The filter which would run for all forms and choice based fields that support the Bulk Add Predefined Choices UI would be used like so:
gform.addFilter( 'gform_load_bulk_choices_choice', function( choice, choiceObj, field ) {
// do stuff

return choice;
} );

Parameters

choice string
The string representing the current choice as a text pattern usually in the format text|value e.g.
One|1

choiceObj Javascript Object
The object representing the choice currently being added to the Bulk Add Predefined Choices UI e.g.
{
"text": "One",
"value": "1",
"isSelected": false,
"price": ""
}

This can also include custom choice properties.

field Javascript Object | Field Object
The current field.

Examples
1. Append custom choice property
This example shows how you can append a custom choice property to the default text|value format.
gform.addFilter( 'gform_load_bulk_choices_choice', function( choice, choiceObj, field ) {
if ( choiceObj.mycustomprop ) {
return choice + '|' + choiceObj.mycustomprop;
}

return choice;
} );

Placement
This code should be placed in a JavaScript file included in the admin by your plugin.
Since
This filter was added in Gravity Forms v2.5.
Source Code
This filter is located in LoadBulkChoices() in form_editor.js.

gform_list_post_item_delete

gform_list_post_item_delete

DescriptionUsageParametersExamples1. Bind Event To List Item InputPlacementSource Code

Description
The 「gform_list_post_item_delete」 JavaScript action in Gravity Forms is fired after an item is deleted from a List field, allowing further actions to be performed.
Usage
gform.addAction( 'gform_list_post_item_delete', function ( container ) {
// do stuff
} );

Parameters

container Javascript Object
The List Field table.

Examples
1. Bind Event To List Item Input
This example shows how you can bind a change event to the new list item input.

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 js/gravityforms.js

gform_list_post_item_add

gform_list_post_item_add

DescriptionUsageParametersExamples1. Bind Event To List Item InputPlacementSource Code

Description
The 「gform_list_post_item_add」 JavaScript action in Gravity Forms is fired after a new item is added to a List field, allowing further actions to be performed.
Usage
123gform.addAction( 'gform_list_post_item_add', function ( item, container ) {    // do stuff} );

Parameters

item Javascript Object
The List Field table row.

container Javascript Object
The List Field table.

Examples
1. Bind Event To List Item Input
This example shows how you can bind a change event to the new list item input.
1234567
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 js/gravityforms.js

gform_list_item_pre_add

gform_list_item_pre_add

DescriptionUsageParametersExamples1. Reset Datepicker Input2. Set Column Input ValuePlacementSource Code

Description
This JavaScript hook can be used to filter new List Field rows before they are added.
Usage
1234gform.addFilter( 'gform_list_item_pre_add', function ( clone ) {    // do stuff    return clone;} );

Parameters

clone Javascript Object
The List Field table row.

group Javascript Object
The List Field table row before being cloned and the inputs cleared. Available from Gravity Forms 1.9.15.1.

Examples
1. Reset Datepicker Input
This example shows how you can reset a datepicker input so the datepicker will function on the new row.
1234567
2. Set Column Input Value
This example shows how you can set the value of the input in the second column of the new row.
123456
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 js/gravityforms.js

gform_list_field_parameter_delimiter

gform_list_field_parameter_delimiter

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
Allow modification of the delimiter used to parse List field URL parameters.
Usage
The following would apply to all forms.
add_filter( 'gform_list_field_parameter_delimiter', 'your_function_name', 10, 4 );

Parameters

$delimiter string
Defaults to 『|』.

$field Field Object
GF_Field object for the current field.

$name string
Name of the current dynamic population parameter.

$field_values array
Array of values provided for pre-population into the form.

Examples
add_filter( 'gform_list_field_parameter_delimiter', function( $delimiter, $field, $name, $field_values ) {
return '||';
}, 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 version 1.9.18.
Source Code
This filter is located in GFFormsModel::get_parameter_value() in forms_model.php.

gform_leads_before_export

gform_leads_before_export

DescriptionUsageParametersExamplesPlacementSource Code

Description
Allows entries to be changed before export is executed.
Usage
Apply to all forms.
add_filter( 'gform_leads_before_export', 'my_modify_entries_before_export_function', 10, 3 );

Apply to a specific form.
add_filter( 'gform_leads_before_export_{$form_id}', 'my_modify_entries_before_export_function', 10, 3 );

Parameters

$entries array
An array of Entry Object | Entry Objects to be exported.

$form Form Object
The current form.

$paging array
The current paging for the export. Includes the following properties:

offset integer
Increases by 1 with each 「page」 of entries the export has processed.

page_size integer
Defaults to 20.

Examples
This example demonstrates how to use to this hook to modify convert the Entry Object|entry object』s default 「created_by」 property (which is a user ID) to instead output the display name of the user.
add_filter( 'gform_leads_before_export', 'use_user_display_name_for_export', 10, 3 );
function use_user_display_name_for_export( $entries, $form, $paging ) {

foreach( $entries as &$entry ) {

$user = new WP_User( $entry['created_by'] );
if ( ! $user->ID )
continue;

$entry['created_by'] = $user->get( 'display_name' );

}

return $entries;
}

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

gform_is_value_match

gform_is_value_match

DescriptionUsageJavaScript VersionParametersExampleSource CodePHP VersionParametersExampleSource Code

Description
This filter can be used to filter whether the source and target values are a match.
Usage
The gform_is_value_match filter has both a JavaScript version and a PHP version. Both versions may need to be used.
The JavaScript version only overrides the result on the front-end.
12345gform.addFilter('gform_is_value_match', function (isMatch, formId, rule) {    // do stuff     return isMatch;} );
The PHP version overrides the result when the conditional logic is evaluated during submission using the field values saved in the entry.
12345add_filter( 'gform_is_value_match', function ( $is_match, $field_value, $target_value, $operation, $source_field, $rule ) {    // do stuff     return $is_match;}, 10, 6 );
JavaScript Version

Parameters

isMatch boolean
Does the target field』s value match with the rule value?

formId integer
The ID of the form in use.

rule Javascript Object
The current rule object. e.g.
{"fieldId":3,"operator":"<","value":"5"} Example This example shows how you can perform the value and rule comparison for a custom field type which may use a custom method for storing its value. 12345678gform.addFilter('gform_is_value_match', function (isMatch, formId, rule) {    var couponField = jQuery('#field_' + formId + '_' + rule.fieldId).find('#gf_coupon_codes_' + formId);    if (couponField.length) {        return gf_matches_operation(couponField.val(), rule.value, rule.operator);    }     return isMatch;}); Source Code This filter is located in js/conditional_logic.js PHP Version Parameters $is_match boolean Does the target field』s value match with the rule value? $field_value string The field value to use with the comparison. $target_value string The value from the conditional logic rule to use with the comparison. $operation string The conditional logic rule operator. $source_field Field Object The field object for the source of the field value. $rule array The current rule object. Example This example shows how you can perform the value and rule comparison for a field type which may store its value in a custom format. 1234567add_filter( 'gform_is_value_match', function ( $is_match, $field_value, $target_value, $operation, $source_field, $rule ) {    if ( $source_field->type == 'product' && $source_field->inputType == 'price' ) {        return RGFormsModel::matches_operation( GFCommon::to_number( $field_value ), $target_value, $operation );    }     return $is_match;}, 10, 6 );
Source Code
This filter is located in RGFormsModel::is_value_match() in forms_model.php

gform_is_valid_url

gform_is_valid_url

DescriptionUsageParametersExamplesPlacementSource Code

Description
Filters the result of URL validations, allowing for custom validation to be performed.
Usage
add_filter( 'gform_is_valid_url', 'custom_validation', 10, 2 );

Parameters

$is_valid bool
True if valid. False otherwise.

$url string
The URL being validated.

Examples
add_filter( 'gform_is_valid_url', 'custom_validation', 10, 2 );

function custom_validation( $is_valid, $url ) {
// Do something here.
return $is_valid;
}

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

gform_is_valid_notification_to

gform_is_valid_notification_to

DescriptionUsageParametersExamplesPlacementSource Code

Description
Enables users to change the email validation for the TO address on notification pages. Useful to allow merge tags or shortcodes to be added to the TO field.
Usage
add_filter( 'gform_is_valid_notification_to', 'validate_to_email', 10, 4 );

Parameters

$is_valid boolean
The value being filtered. True if the to email is valid. False otherwise. Gravity Forms performs the validation before executing this hook, so $is_valid will contain the result of that validation. To override Gravity Form』s validation, simply set the value of this variable to true or false and return it.

$to_type string
The type of 「Send To」 that is configured. The possible values are 「email」, 「field」 and 「routing」.

$to_email string
The email address configured. Only applies when type ($to_type) is set to 「email」

$to_field string
The ID of the field selected to be used as the 「Send To」. Only applies when type ($to_type) is set to 「field」

Examples
The following example demostrates how to allow the merge tag {user:user_email} to be used for notificatons 「Send To」 email
add_filter( 'gform_is_valid_notification_to', 'validate_to_email', 10, 4 );
function validate_to_email( $is_valid, $to_type, $to_email, $to_field ) {

if ( $to_email == '{user:user_email}' ) {
return true;
}

return $is_valid;
}

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

gform_is_valid_formula_form_editor

gform_is_valid_formula_form_editor

DescriptionUsageParametersExamplesSinceSource Code

Description
JavaScript filter allowing the formula validation result to be overridden in the form editor.
Usage
gform.addFilter( 'gform_is_valid_formula_form_editor', function( result, formula ) {
// do stuff

return result;
} );

Parameters

result string
The validation result.

formula string
The calculation formula being validated.

Examples
add_action( 'gform_admin_pre_render', 'check_formula' );
function check_formula( $form ){
?>