gform_footer_init_scripts_filter

gform_footer_init_scripts_filter

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
Allows the scripts that fire in the footer to be modified.
Note: The gform_init_scripts_footer must be set to true so scripts are initialized in the footer of the site instead of the page body.
Usage
The following would apply to all forms:
add_filter( 'gform_footer_init_scripts_filter', 'your_function_name', 10, 3 );

To target a specific form, append the form id to the hook name. (format: gform_footer_init_scripts_filter_FORMID)
add_filter( 'gform_footer_init_scripts_filter_1', 'your_function_name', 10, 3 );

Parameters

$form_string string
A string of the scripts used in the footer.

$form Form Object
The current form.

$current_page int
The ID of the current page.

Example
add_filter( 'gform_footer_init_scripts_filter', 'filter_footer', 10, 3 );
function filter_footer( $form_string, $form, $current_page ){
$form_string .= "";
return $form_string;
}

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.8.4.
Source Code
This filter is located in GFFormDisplay::footer_init_scripts() in form_display.php.

gform_filters_pre_results

gform_filters_pre_results

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to modify the filters used in the drop down list of fields in the admin results page. The results page is currently only used by add-ons that implement the Add-On Framework.
Usage
1add_filter( 'gform_filters_pre_results', 'your_function_name', 10, 2 );

Parameters

$filter_settings array
The array of filters.

$form Form Object
The form object.

Examples
This example removes payment related info fields from the filters.
123456789add_filter( 'gform_filters_pre_results', 'remove_payment_filters', 10, 2 );function remove_payment_filters( $filter_settings, $form ) {    foreach ( $filters as $i => $filter ) {        if ( in_array( $filter_settings['key'], array( 'payment_amount', 'payment_date', 'payment_status', 'transaction_id' ) ) ) {            unset( $filter_settings[ $i ] );        }    }    return $filter_settings;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
1apply_filters( 'gform_filters_pre_results', $filter_settings, $form );
This filter is located in GFResults::results_page() in includes/addon/class-gf-results.php.

gform_filters_get_users

gform_filters_get_users

DescriptionUsageParametersExamplesPlacementSource Code

Description
Use this filter to control the list of users available in the filters on the entry list, export entries conditional logic and results pages.
Usage
add_filter( 'gform_filters_get_users', 'your_function_name' );

Parameters

$args array
array( 'number' => 200 )
The array of options to use when filtering the users. See the get_users() Function Reference on the WordPress codex for further details: https://developer.wordpress.org/reference/functions/get_users/

Examples
This example lists only the users from the role 「administrator」.
add_filter( 'gform_filters_get_users', 'filters_get_users_args' );
function api_get_users_args( $args ) {
$args['role'] = 'administrator';
return $args;
}

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
apply_filters( 'gform_filters_get_users', array( 'number' => 200 ) )

This action hook is located in GFCommon::get_entry_info_filter_columns() in common.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_fileupload_entry_value_file_path

gform_fileupload_entry_value_file_path

DescriptionUsageParametersPlacementSource Code

Description
Allows for the filtering of the file path before output.
Usage
The following would apply to all forms.
1add_filter( 'gform_fileupload_entry_value_file_path', 'your_function_name', 10, 2 );

Parameters

$file_path string
The file path of the download file.

$field GF_Field_Fileupload
The field object for further context.

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in class-gf-field-fileupload.php.

gform_file_upload_whitelisting_disabled

gform_file_upload_whitelisting_disabled

DescriptionUsageParametersExamplePlacementSource Code

Description
The 「gform_file_upload_whitelisting_disabled」 filter in Gravity Forms allows the disabling of file upload whitelisting. This filter applies to all forms.
Usage
The following would apply to all forms.
add_filter('gform_file_upload_whitelisting_disabled', '__return_true');

Parameters

$disabled bool
Set to 『true』 to disable whitelisting. Defaults to 『false』.

Example
$whitelisting_disabled = apply_filters( 'gform_file_upload_whitelisting_disabled', false );

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

gform_file_upload_status_markup

gform_file_upload_status_markup

DescriptionUsageParametersExamplesSinceSource Code

Description
JavaScript filter allowing the file upload markup to be filtered as it is being uploaded.
Usage

Parameters

statusMarkup string
Markup template used to render the status of the file being uploaded.

file {plupload.File}
Instance of File being uploaded. See: https://www.plupload.com/docs/v2/File.

size integer|string
File size.

strings object
Array of localized strings relating to the file upload UI.

removeFileJs string
JS used to remove the file when the 「Cancel」 link is click/pressed.

up {plupload.Uploader}
Instance of Uploader responsible for uploading current file. See: https://www.plupload.com/docs/v2/Uploader.

Examples

Since
This filter was added in Gravity Forms version 2.4.8.3.
Source Code
This filter is located in gravityforms/js/gravityforms.js.

gform_file_upload_markup

gform_file_upload_markup

DescriptionUsageJavaScript VersionParametersExamplesChange delete buttonAccess temporary filenamePlacementSource CodePHP VersionParametersExamplePlacementSource Code

Description
The 「gform_file_upload_markup」 filter can be used to modify the HTML for the multi-file upload 「preview」.
Usage
The gform_file_upload_markup filter has both a JavaScript version and a PHP version. Both versions should be used.
The JavaScript version modifies the HTML the first time the uploaded file preview displays.
gform.addFilter( 'gform_file_upload_markup', function( html, file, up, strings, imagesUrl, response ) {
// do stuff

return html;
} );

The PHP version changes the uploaded file preview HTML on a multi-page form when you click Previous/Next after a file has been uploaded.
add_filter( 'gform_file_upload_markup', function( $file_upload_markup, $file_info, $form_id, $field_id ) {
// do stuff

return $result;
}, 10, 4 );

JavaScript Version

Parameters

html string
The current html for the field.

file Javascript Object
Details about the file uploaded.

up Javascript Object
The FileUpload object.

strings Javascript Object
Strings used for upload messages.

imagesUrl string
The URL to the images folder.

response Javascript Object
The response from GFAsyncUpload. Since version 2.4.22.3.
{
"status": "ok",
"data": {
"temp_filename": "randomly-generated-temp-filename-here.png",
"uploaded_filename": "image.png"
}
}

Examples
Change delete button
This example shows how to change the delete button that is next to the uploaded file.
gform.addFilter('gform_file_upload_markup', function (html, file, up, strings, imagesUrl) {
var formId = up.settings.multipart_params.form_id,
fieldId = up.settings.multipart_params.field_id;
html = '' + file.name + " ";

return html;
});

Access temporary filename
This example shows how you can access the temporary file name of the uploaded file with Gravity Forms 2.4.22.3 and greater.
gform.addFilter( 'gform_file_upload_markup', function( html, file, up, strings, imagesUrl, response ) {
var temp_name = rgars( response, 'data/temp_filename' );
// Do something with the temp_name.

return html;
} );

Placement
Your code snippet can be placed in an HTML field on your form or in the theme』s custom JavaScript file that loads on the form』s page.
Source Code
This filter is located in js/gravityforms.js.
PHP Version

Parameters

$file_upload_markup string
The current html for the field.

$file_info array
Details about the file uploaded.

$form_id integer
Form ID.

$field_id integer
Field ID.

Example
This example shows how to change the delete button that is next to the uploaded file.
add_filter( 'gform_file_upload_markup', 'change_upload_markup', 10, 4 );

function change_upload_markup( $file_upload_markup, $file_info, $form_id, $field_id ) {
return '' . esc_html( $file_info['uploaded_filename'] ) . " ";
}

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GF_Field_FileUpload::get_field_input() in gravityforms/includes/fields/class-gf-field-fileupload.php.

gform_file_permission

gform_file_permission

DescriptionUsageParametersExamplesSource Code

Description
This filter is executed when uploading a file. It can be used to change the default permissions of uploaded files.
Usage
Applies to all forms.
1add_filter( 'gform_file_permission', 'set_file_permission', 10, 2 );
Parameters

$permission string
The file permission to be filtered (i.e. 0755).

$path string
The full file path.

Examples
This example changes the permissions of uploaded files to 0755.
12345add_filter( 'gform_file_permission', 'set_file_permission', 10, 2 );function set_file_permission( $permission, $path ) {    // Note the octal value with the leading zero. Don't return a string.    return 0755;}
Source Code
This filter is located in GFFormsModel::set_permissions() in forms_model.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.