GFORM_DB_MIGRATION_BATCH_SIZE

GFORM_DB_MIGRATION_BATCH_SIZE

DescriptionUsagePlacement

Description
The database schema was changed with Gravity Forms version 2.3. When upgrading from previous versions, the upgrade occurs in the background in batches. This constant allows the batch size to be changed from the default of 20000.
Usage
1define( 'GFORM_DB_MIGRATION_BATCH_SIZE', 50000 );
Placement
This constant should be set in your wp-config.php. See the article Wp Config Options for more details.

gform_datepicker_options_pre_init

gform_datepicker_options_pre_init

DescriptionUsageParametersExamples1. Weekends only2. No Weekends3. Datepicker 1 becomes minDate for datepicker 24. Datepicker 1 + 1 month becomes minDate for datepicker 25. Disable specific dates6. Restrict selectable dates to specific ranges7. Disable specific dates and a certain day of the week8. Setting local translations9. Disable past dates10. Disable month and year selection11. Disable specific months12. Force week to start on MondayPlacementSource Code

Description
This filter can be used to modify the options used to initialize a fields datepicker.
The Gravity Forms Datepicker is powered by the jQuery UI Datepicker which is bundled with WordPress. See jQuery UI API Documentation – Datepicker Widget for all the possible options you can use with this filter.
Usage

Parameters

optionsObj Javascript Object
The current datepicker object.
{
yearRange: '-100:+20',
showOn: 'focus',
dateFormat: 'mm/dd/yy',
changeMonth: true,
changeYear: true,
suppressDatePicker: false,
onClose: function () {
element.focus();
var self = this;
this.suppressDatePicker = true;
setTimeout(function () {
self.suppressDatePicker = false;
}, 200);
},
beforeShow: function (input, inst) {
return !this.suppressDatePicker;
}
}

formId integer
The ID of the current form.

fieldId integer
The ID of the current field.

Examples
1. Weekends only
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 12 && fieldId == 1 ) {
optionsObj.firstDay = 1;
optionsObj.beforeShowDay = function(date) {
var day = date.getDay();
return [(day == 0 || day == 6)];
};
}
return optionsObj;
});

2. No Weekends
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 12 && fieldId == 6 ) {
optionsObj.firstDay = 1;
optionsObj.beforeShowDay = jQuery.datepicker.noWeekends;
}
return optionsObj;
});

3. Datepicker 1 becomes minDate for datepicker 2
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 12 && fieldId == 8 ) {
optionsObj.minDate = 0;
optionsObj.onClose = function (dateText, inst) {
jQuery('#input_12_9').datepicker('option', 'minDate', dateText).datepicker('setDate', dateText);
};
}
return optionsObj;
});

4. Datepicker 1 + 1 month becomes minDate for datepicker 2
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 12 && fieldId == 11 ) {
optionsObj.minDate = 0;
optionsObj.onClose = function (dateText, inst) {
dateText = new Date(dateText);
dateMin = new Date(dateText.getFullYear(), dateText.getMonth() + 1,dateText.getDate());
jQuery('#input_12_12').datepicker('option', 'minDate', dateMin).datepicker('setDate', dateMin);
};
}
return optionsObj;
});

5. Disable specific dates
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 12 && fieldId == 14 ) {
var disabledDays = ['06/15/2014', '07/01/2014', '07/15/2014'];
optionsObj.beforeShowDay = function(date) {
var checkdate = jQuery.datepicker.formatDate('mm/dd/yy', date);
return [disabledDays.indexOf(checkdate) == -1];
};
}
return optionsObj;
});

6. Restrict selectable dates to specific ranges
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 12 && fieldId == 16 ) {
var ranges = [
{ start: new Date('06/15/2014'), end: new Date('06/25/2014') },
{ start: new Date('07/15/2014'), end: new Date('07/25/2014') },
{ start: new Date('08/15/2014'), end: new Date('08/25/2014') }
];
optionsObj.beforeShowDay = function(date) {
for ( var i=0; i= ranges[i].start && date <= ranges[i].end ) return [true, '']; } return [false, '']; }; optionsObj.minDate = ranges[0].start; optionsObj.maxDate = ranges[ranges.length -1].end; } return optionsObj; }); 7. Disable specific dates and a certain day of the week gform.addFilter('gform_datepicker_options_pre_init', function (optionsObj, formId, fieldId) { if (formId == 149 && fieldId == 2) { optionsObj.firstDay = 1; optionsObj.beforeShowDay = function (date) { var disabledDays = ['06/15/2015', '06/16/2015', '06/18/2015'], currentDate = jQuery.datepicker.formatDate('mm/dd/yy', date), day = date.getDay(); return [!(disabledDays.indexOf(currentDate) != -1 || day == 3)]; }; } return optionsObj; }); 8. Setting local translations The below example will set the default region to France, which will include translations. Note: This assumes that the translation file is already present and enqueued. See the Translating The Datepicker article. gform.addFilter('gform_datepicker_options_pre_init', function (optionsObj, formId, fieldId) { if (formId == 149 && fieldId == 2) { jQuery.datepicker.regional['fr'] } return optionsObj; }); 9. Disable past dates The snippet below will disable any past date and allow only to select current and future dates. gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) { // Apply to field 2 only if ( fieldId == 2 ) { optionsObj.minDate = 0; } return optionsObj; }); 10. Disable month and year selection gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) { if ( formId == 381 && fieldId == 2 ) { // Update form and field id in this line optionsObj.changeMonth = false; optionsObj.changeYear = false; } return optionsObj; }); 11. Disable specific months The following example will disable date selection for months January, April, and July in a datepicker field with id 1 in a form with id 1744. gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) { if ( formId == 1744 && fieldId == 1 ) { // Months to disable (0 for January, 1 February, etc...) monthsDisabled = [0, 3, 6]; optionsObj.beforeShowDay = function(date) { if (jQuery.inArray(date.getMonth(), monthsDisabled) > -1) {
return [false, ''];
}
return [true, ''];
};
}
return optionsObj;
});

12. Force week to start on Monday
The following example uses the firstDay parameter to force the week to start on Monday.
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
// Sunday is 0, Monday is 1, etc.
optionsObj.firstDay = 1;
return optionsObj;
});

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

gform_date_min_year

gform_date_min_year

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to specify the minimum year displayed in the date field』s year drop down and the HTML5 min attribute for the date field』s year input.
Usage
add_filter( 'gform_date_min_year', 'set_min_year' );

Parameters

$min_date string
The minimum date to be filtered. Defaults to 1920.

$form Form Object
Current form object.

$field Field Object
Current field object.

Examples
This example changes the minimum date to 1900.
add_filter( 'gform_date_min_year', 'set_min_year' );
function set_min_year( $min_year ) {
return 1900;
}

This example changes the min date for a specific field on a specific form.
add_filter( 'gform_date_min_year', function ( $min_year, $form, $field ) {

return $form['id'] == 7 && $field->id == 5 ? 2014 : $min_year;
}, 10, 3 );

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in the following methods in includes/fields/class-gf-field-date.php:

GF_Field_Date::get_field_input()
GF_Field_Date::get_year_dropdown()

gform_date_max_year

gform_date_max_year

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to specify the maximum year displayed in the date field』s year drop down and the HTML5 max attribute for the date field』s year input.
Usage
add_filter( 'gform_date_max_year' , 'set_max_year' );

Parameters

$max_date string
The maximum date to be filtered. Defaults to the current year plus one.

$form Form Object
Current form object.

$field Field Object
Current field object.

Examples
This example changes the max date to 2022.
add_filter( 'gform_date_max_year', 'set_max_year' );
function set_max_year( $max_year ) {
return 2022;
}

This example changes the max date for a specific field on a specific form.
add_filter( 'gform_date_max_year', function ( $max_year, $form, $field ) {

return $form['id'] == 7 && $field->id == 5 ? 2022 : $max_year;
}, 10, 3 );

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in the following methods in includes/fields/class-gf-field-date.php:

GF_Field_Date::get_field_input()
GF_Field_Date::get_year_dropdown()

gform_dashboard_title

gform_dashboard_title

DescriptionUsageExamplesPlacementSource Code

Description
This filter allows the title of the forms statistics section displayed on the Dashboard to be changed.
Usage
1add_filter( 'gform_dashboard_title', 'set_dashboard_title' );
Examples
12345add_filter( 'gform_dashboard_title', 'set_dashboard_title' );function set_dashboard_title() {    //change the title of the Forms Dashboard    return "May The Forms Be With You";}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFForms::dashboard_setup() in gravityforms.php

gform_custom_merge_tags

gform_custom_merge_tags

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
Allows for the inclusion of custom merge tags wherever merge tag drop downs are generated.
Usage
add_filter( 'gform_custom_merge_tags', 'your_function_name', 10, 4 );

Parameters

$merge_tags array
The merge tags.

$form_id int
The ID of the current form.

$fields Field Object
A collection of field objects.

$element_id int
The ID of the input field.

Example
add_filter('gform_custom_merge_tags', 'custom_merge_tags', 10, 4);
function custom_merge_tags( $merge_tags, $form_id, $fields, $element_id ) {
$merge_tags[] = array('label' => 'Download Link', 'tag' => '{download_link}');
return $merge_tags;
}

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.6.2.
Source Code
This filter is located in:
GFCommon::get_merge_tags() in common.php
GFCommon::insert_calculation_variables() in common.php

gform_currency

gform_currency

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to override the currency configured on the Forms > Settings page. It will affect all forms.
Usage
1add_filter( 'gform_currency', 'your_function_name' );

Parameters

$currency string
The currency code to be filtered.

Examples
This example forces the current currency to USD (US dollars).
1234add_filter( 'gform_currency', 'usd_currency' );function usd_currency( $currency ) {    return 'USD';}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
1apply_filters( 'gform_currency', $currency )
This filter is located in GFCommon::get_currency() in common.php.

gform_currency_setting_message

gform_currency_setting_message

DescriptionUsageParametersExamplesPlacementSource Code

Description
The gform_currency_setting_message action hook is used to add a message after the currency drop down within the Settings page.
Usage
add_action( 'gform_currency_setting_message', 'currency_message' );

Parameters

$message string
The default message. An empty string.

Examples
This example adds a message below the currency drop down.
add_action( 'gform_currency_setting_message', 'currency_message' );
function currency_message() {
esc_html_e( 'US Dollars is the only supported currency by this payment gateway.', 'your_text_domain_here' );
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This action hook was originally located in GFSettings::gravityforms_settings_page() in settings.php. In Gravity Forms 2.5 it was moved to GFSetting::currency_message_callback().

gform_currency_setting_message

gform_currency_setting_message

DescriptionUsageParametersExamplesPlacementSource Code

Description
The gform_currency_setting_message action hook is used to add a message after the currency drop down within the Settings page.
Usage
add_action( 'gform_currency_setting_message', 'currency_message' );

Parameters

$message string
The default message. An empty string.

Examples
This example adds a message below the currency drop down.
add_action( 'gform_currency_setting_message', 'currency_message' );
function currency_message() {
esc_html_e( 'US Dollars is the only supported currency by this payment gateway.', 'your_text_domain_here' );
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This action hook was originally located in GFSettings::gravityforms_settings_page() in settings.php. In Gravity Forms 2.5 it was moved to GFSetting::currency_message_callback().

gform_currency_pre_save_entry

gform_currency_pre_save_entry

DescriptionUsageParametersExamplePlacementSource CodeSince

Description
This filter can be used to override the default currency code before the entry is saved.
Usage
The base filter which would run for all forms would be used like so:
add_filter( 'gform_currency_pre_save_entry', 'your_function_name', 10, 2 );

To target a specific form append the form id to the hook name. (format: gform_currency_pre_save_entry_FORMID)
add_filter( 'gform_currency_pre_save_entry_5', 'your_function_name', 10, 2 );

Parameters

$currency string
The three character ISO currency code to be stored in the entry. Default is value returned by GFCommon::get_currency()

$form Form Object
The form currently being processed.

Example
This example shows how you can override the currency code with a value from a form field.
add_filter( 'gform_currency_pre_save_entry', 'override_currency_code', 10, 2 );
function override_currency_code( $currency, $form ) {

return rgpost( 'input_7' );
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
gf_apply_filters( 'gform_currency_pre_save_entry', $form['id'], GFCommon::get_currency(), $form )

This filter is located in GFFormsModel::create_lead and GFFormsModel::save_lead in forms_model.php.
Since
This filter was added in Gravity Forms 1.9.13.26.