gform_field_value_$parameter_name

gform_field_value_$parameter_name

DescriptionUsageParametersExamplesPopulate a fixed datePopulate from a cookieList FieldOld Array FormatNew Array FormatPopulate multiple fields using one functionPopulate the timePopulate current datePopulate previous valuePlacementSource Code

Description
This filter is executed before displaying each field and can be used to dynamically populate fields with a default value.
This filter can also be used to pre-select or pre-check drop down, radio button and checkbox items.
Note: This filter requires that the 「Allow field to be populated dynamically」 option is checked in the field editor』s advanced tab.
Usage
add_filter( 'gform_field_value_email', 'your_function_name' );

You can also use the filter without including a parameter name e.g.
add_filter( 'gform_field_value', 'your_function_name' );

Parameters

$value string
The string containing the current field value to be filtered.

$field Field Object
The current field being processed.

$name string
The parameter name of the field or input being processed.

Examples
Populate a fixed date
The following example populates the date field with a hard-coded value. It assumes that the date field is configured to 「Allow field to be populated dynamically」 and that the parameter name is set to 「date」
add_filter( 'gform_field_value_date', 'populate_date' );
function populate_date( $value ) {
return '10/10/2010';
}

Populate from a cookie
The following example populates a hidden field with content from a cookie. It assumes that the hidden field is configured to 「Allow field to be populated dynamically」 and that the parameter name is set to 「utm_campaign」 and the cookie has the same name.
add_filter( 'gform_field_value_utm_campaign', 'populate_utm_campaign' );
function populate_utm_campaign( $value ) {
return $_COOKIE['utm_campaign'];
}

List Field
The following examples populate a 3 column list field with some values. It assumes that the list field is configured to 「Allow field to be populated dynamically」 and that the parameter name is set to 「list」. The second example accepts a new array format that is available as of Gravity Forms 1.9.10.8. This format is the same format in which the data is saved in the database and much more user friendly. Example one is left for backwards compatibility since this format is still accepted.
Old Array Format
add_filter( 'gform_field_value_list', 'populate_list' );
function populate_list( $value ) {
return array( 'row 1 - col1', 'row 1 - col2', 'row 1 - col3',
'row 2 - col1', 'row 2 - col2', 'row 2 - col3',
'row 3 - col1', 'row 3 - col2', 'row 3 - col3' );

}

New Array Format
add_filter( 'gform_field_value_list', 'populate_list' );
function populate_list( $value ) {
$list_array = array(
array(
'Column 1' => 'row1col1',
'Column 2' => 'row1col2',
'Column 3' => 'row1col3',
),
array(
'Column 1' => 'row2col1',
'Column 2' => 'row2col2',
'Column 3' => 'row2col3'
),
);
return $list_array;
}

Populate multiple fields using one function
add_filter( 'gform_field_value', 'populate_fields', 10, 3 );
function populate_fields( $value, $field, $name ) {

$values = array(
'field_one' => 'value one',
'field_two' => 'value two',
'field_three' => 'value three',
);

return isset( $values[ $name ] ) ? $values[ $name ] : $value;
}

Populate the time
The following example populates the time field with the current time. It assumes that the date field is configured to 「Allow field to be populated dynamically」 and that the parameter name is set to 「time」
add_filter( 'gform_field_value_time', 'populate_time' );
function populate_time( $value ) {
$local_timestamp = GFCommon::get_local_timestamp( time() );

return date_i18n( 'h:i A', $local_timestamp, true );
}

Populate current date
The following example populates a date field with the current date. It assumes that the date field is configured to 「Allow field to be populated dynamically」 and that the parameter name is set to 「current_date」
add_filter( 'gform_field_value_current_date', 'populate_current_date' );
function populate_current_date( $value ) {
$local_timestamp = GFCommon::get_local_timestamp( time() );

return date_i18n( 'm/d/Y', $local_timestamp, true );
}

Populate previous value
The following example shows how a field can be populated with the previous value submitted for the current form and field by the logged in user. In this case the dynamic population parameter name setting on the field is set to 「previous_value」.
add_filter( 'gform_field_value_previous_value', 'populate_previous_value', 10, 2 );
function populate_previous_value( $value, $field ) {
$entries = GFAPI::get_entries(
$field->formId,
array(
'field_filters' => array(
array(
'key' => 'created_by',
'value' => get_current_user_id(),
),
),
),
array(),
array( 'page_size' => 1 )
);

return rgars( $entries, '0/' . $field->id );
}

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

gform_form_args

gform_form_args

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
The filter gform_form_args provides the ability to modify the options used to display the form.
Usage
1add_filter( 'gform_form_args', 'your_function_name', 10, 1 );

Parameters

$form_args array
An array of Form Arguments when adding it to a page/post (like the ID, Title, AJAX or not, etc.). Possible values in array:

form_id – the form id or title
display_title – true/false
display_description – true/false
force_display – true/false
field_values – An array of dynamic population parameter keys with their corresponding values to be populated.
ajax – true/false
tabindex – number

Examples
1234567add_filter( 'gform_form_args', 'setup_form_args' );function setup_form_args( $form_args ) {    $form_args['display_title'] = false;    $form_args['display_description'] = true;     return $form_args;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms 1.9.
Source Code
This filter is located in GFFormDisplay::get_form() in form_display.php.

gform_field_settings_tabs

gform_field_settings_tabs

DescriptionUsageParametersExamples1. Add a new tabPlacementSinceSource Code

Description
The gform_field_settings_tabs filter enables new tabs to be registered for display in the field settings panel in the form editor. Use the gform_field_settings_tab_content action hook to echo the tab content.
Usage
The filter which would run for all forms would be used like so:
1add_filter( 'gform_field_settings_tabs', 'your_function_name', 10, 2 );
You can also target a specific form by adding the form id after the hook name.
1add_filter( 'gform_field_settings_tabs_6', 'your_function_name', 10, 2 );

Parameters

$tabs array
An array of custom field settings tabs.

$form Form Object
The form currently being edited.

Examples
1. Add a new tab
1234567891011121314add_filter( 'gform_field_settings_tabs', function ( $tabs, $form ) {    $tabs[] = array(        // Define the unique ID for your tab.        'id'             => 'my_custom_tab_1',        // Define the title to be displayed on the toggle button your tab.        'title'          => 'My Custom Tab',        // Define an array of classes to be added to the toggle button for your tab.        'toggle_classes' => array( 'my_toggle_class_1', 'my_toggle_class_2' ),        // Define an array of classes to be added to the body of your tab.        'body_classes'   => array( 'my_body_class_1' ),    );     return $tabs;}, 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme or a custom functions plugin.
Since
This filter was added in Gravity Forms v2.5.
Source Code
This filter is located in GFFormDetail::forms_page() in form_detail.php

gform_form_settings_fields

gform_form_settings_fields

DescriptionUsageParametersExamplesAdd a new fieldPlacementSinceSource Code

Description

The gform_form_settings_fields filter is used to customize the available settings on the Form Settings page.

Usage

The filter which runs for all would be used like so:

add_filter( 'gform_form_settings_fields', 'your_function_name', 10, 2 );

You can also target a specific form by adding the form id after the hook name.

add_filter( 'gform_form_settings_fields_6', 'your_function_name', 10, 2 );

Parameters

$fields array
The Form Settings fields. See the Settings API for details about how the fields are defined.

$form Form Object
The current form.

Examples

Add a new field

This example would add a hidden field to the Form Options section of the Form Settings page.

add_filter( 'gform_form_settings_fields', function ( $fields, $form ) {
$fields['form_options']['fields'][] = array( 'type' => 'hidden', 'name' => 'my_custom_hidden_field' );

return $fields;
}, 10, 2 );

Placement

This code should be placed in the functions.php file of your active theme or a custom functions plugin.

Since

This filter was added in Gravity Forms v2.5.

Source Code

This filter is located in GFFormSettings::form_settings_fields() in form_settings.php.

gform_filter_links_entry_list

gform_filter_links_entry_list

DescriptionUsageParametersExamplesBasic usage.Filter entries by field value.Add a filter for 「Not Starred」 entries.PlacementSinceSource Code

Description
The 「gform_filter_links_entry_list」 filter in Gravity Forms allows the list of filters at the top of the Entry List page to be modified.
Usage
add_filter( 'gform_filter_links_entry_list', 'your_function_name', 10, 3 );

Parameters

$filter_links array
An array of each filter link. Sample array:
array (
0 =>
array (
'id' => 'all',
'field_filters' =>
array (
),
'count' => '',
'label' => 'All',
),
1 =>
array (
'id' => 'unread',
'field_filters' =>
array (
0 =>
array (
'key' => 'is_read',
'value' => false,
),
),
'count' => '',
'label' => 'Unread',
),
2 =>
array (
'id' => 'star',
'field_filters' =>
array (
0 =>
array (
'key' => 'is_starred',
'value' => true,
),
),
'count' => '',
'label' => 'Starred',
),
3 =>
array (
'id' => 'spam',
'field_filters' =>
array (
),
'count' => '',
'label' => 'Spam',
),
4 =>
array (
'id' => 'trash',
'field_filters' =>
array (
),
'count' => '',
'label' => 'Trash',
),
)

$form Form Object
The current form.

$include_counts bool

Examples
Basic usage.
This example will simply add the 『My Custom Link』 to the Entries list page. It will not filter anything because it has a blank array for 『field_filters』. So you would need to provide your own filter to make it work.
add_filter( 'gform_filter_links_entry_list', 'change_links', 10, 3 );
function change_links( $filter_links, $form, $include_counts ){
$filter_links[] = array(
'id' => 'mycustom',
'field_filters' => array(), // You need to provide a filter array here to make this link do something.
'label' => 'My Custom Link',
);
return $filter_links;
}

Filter entries by field value.
The following example will add a new 『Value test for Field id 1』 link that will reduce the entries list to only entries where field ID 1 has test as value.
// Filter Entries List to show only entries with value 'test' for field id 1.
add_filter( 'gform_filter_links_entry_list', 'filter_list_by_field_value', 10, 3 );
function filter_list_by_field_value( $filter_links, $form, $include_counts ){
$filter_links[] = array(
'id' => 'filterbyfield',
'field_filters' =>
array (
0 =>
array (
'key' => 1, // ID of the field to check.
'value' => 'test', // Only entries with this value for the above field id.
),
),
'label' => 'Value test for Field id 1',
);
return $filter_links;
}

Add a filter for 「Not Starred」 entries.
The following example will add a new 『Not Starred』 link that will filter the entries list to show only entries where the is_starred property is set to false (entries with the gray star icon).
add_filter( 'gform_filter_links_entry_list', 'add_not_starred_filter', 10, 3 );
function add_not_starred_filter( $filter_links, $form, $include_counts ) {

$summary = $include_counts ? GFFormsModel::get_form_counts( $form['id'] ) : array();

$active_entry_count = absint( rgar( $summary, 'total' ) );
$starred_count = absint( rgar( $summary, 'starred' ) );

$filter_links[] = array(
'id' => 'no-star',
'field_filters' => array(
array( 'key' => 'is_starred', 'value' => false ),
),
'count' => $active_entry_count - $starred_count,
'label' => esc_html_x( 'Not Starred', 'Entry List', 'gravityforms' ),
);

return $filter_links;
}

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.15.
Source Code
This filter is located in GFEntryList::get_filter_links() in entry_list.php.

gform_form_not_found_message

gform_form_not_found_message

DescriptionUsageParametersExamplePlacementSource Code

Description
The 「gform_form_not_found_message」 filter in Gravity Forms allows the default form message, 「Oops! We could not locate your form.」 to be changed.
Usage
add_filter( 'gform_form_not_found_message', 'your_function_name', 10, 2 );

Parameters

$message string
The default form not found message.

$id int
The ID of the form attempted to be used.

Example
add_filter( 'gform_form_not_found_message', 'change_message', 10, 2 );
function change_message( $message, $id ){
return "We could not find the form with id " . $id;
}

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFFormDisplay::get_form() in gravityforms/form_display.php.

gform_file_path_pre_delete_file

gform_file_path_pre_delete_file

DescriptionUsageParametersExamples1. Log the current path2. Change the pathPlacementSinceSource Code

Description
The gform_file_path_pre_delete_file filter is executed before an uploaded file (from the File Upload or Post Image fields) is deleted from the entry. It can be used in conjunction with the gform_upload_path filter when changing the location where uploaded files are stored.
Usage
The following would apply to all forms.
add_filter( 'gform_file_path_pre_delete_file', 'your_function_name', 10, 2 );

Parameters

$file_path string
The path of the file to be deleted.

$url string
The url of the file to be deleted.

Examples
1. Log the current path
You can use this example when Logging And Debugging to find out what the current path and url are before using the next example to change the path.
add_filter( 'gform_file_path_pre_delete_file', function ( $file_path, $url ) {
GFCommon::log_debug( 'gform_file_path_pre_delete_file: path of file to be deleted => ' . $file_path );
GFCommon::log_debug( 'gform_file_path_pre_delete_file: url of file to be deleted => ' . $url );

return $file_path;
}, 1, 2 );

2. Change the path
This example changes the path of the file to be deleted.
add_filter( 'gform_file_path_pre_delete_file', 'change_file_path', 10, 2 );
function change_file_path( $file_path, $url ) {
$file_path = '/home/public_html/yourdomainfolder/new/path/filename.pdf';

return $file_path;
}

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms 2.2.3.1.
Source Code
This filter is located in GFFormsModel::delete_physical_file() in forms_model.php.

gform_field_size_choices

gform_field_size_choices

DescriptionUsageParametersExamples1. Add custom sizePlacementSinceSource Code

Description
The gform_field_size_choices filter allows the choices for Field Size setting in the form editor to be customized.
Usage
add_filter( 'gform_field_size_choices', 'your_function_name' );

Parameters

$choices array
An array of choices (value and text) to be included in the Field Size setting. The default choices are defined like so:
$choices = array(
array( 'value' => 'small', 'text' => __( 'Small', 'gravityforms' ) ),
array( 'value' => 'medium', 'text' => __( 'Medium', 'gravityforms' ) ),
array( 'value' => 'large', 'text' => __( 'Large', 'gravityforms' ) ),
);

Examples
1. Add custom size
This example shows how you can add a custom size.
add_filter( 'gform_field_size_choices', function( $choices ) {
$choices[] = array( 'value' => 'custom', 'text' => 'Custom' );

return $choices;
} );

Placement
This code can be placed in the functions.php file of your active theme or a custom functions plugin.
Since
This filter was added in Gravity Forms 2.4.18.13.
Source Code
$choices = apply_filters( 'gform_field_size_choices', $choices );

This filter is located in GF_Field::get_size_choices() in includes/fields/class-gf-field.php.

gform_form_settings_initial_values

gform_form_settings_initial_values

DescriptionUsageParametersExamples1. Enable HoneypotPlacementSinceSource Code

Description

The filter gform_form_settings_initial_values allows the initial values that will be populated into the form settings to be overridden.

Usage

The filter which would run for all forms would be used like so:

add_filter( 'gform_form_settings_initial_values', 'your_function_name', 10, 2 );

Parameters

$initial_values arrayAn associative array of setting names and their initial values.$form Form ObjectThe form currently being edited.

Examples

1. Enable Honeypot

add_filter( 'gform_form_settings_initial_values', function( $initial_values, $form ) {
$initial_values['enableHoneypot'] = true;

return $initial_values;
}, 10, 2 );

Placement

This code should be placed in the functions.php file of your active theme or a custom functions plugin.

Since

This filter was added in Gravity Forms v2.5.

Source Code

This filter is located in GFFormSettings::get_initial_values() in form_settings.php.