gform_settings_menu

gform_settings_menu

DescriptionUsageParametersExamples1. Add tab2. Remove tabPlacementSource Code

Description
Use this filter to add/remove tabs to/form the main Gravity Forms settings page.
If creating a Gravity Forms Add-On, consider using the Add-On Framework instead as it provides many other features.
Usage
add_filter( 'gform_settings_menu', 'add_custom_settings_tab' );

Parameters

$tabs array
An array of tabs to be filtered, in the following format:
array(
array( 'name' => 'tab1', 'label' => 'Settings 1' ),
array( 'name' => 'tab2', 'label' => 'Settings 2' )
)

Examples
1. Add tab
The following example demonstrates how to add a custom settings tab.
add_filter( 'gform_settings_menu', 'add_custom_settings_tab' );
function add_custom_settings_tab( $tabs ) {
$tabs[] = array( 'name' => 'my_tab', 'label' => 'My Settings' );
return $tabs;
}

2. Remove tab
The following example shows how tabs can be removed. For add-ons which extend the offical Gravity Forms add-on framework the tab name will be the add-on slug.
add_filter( 'gform_settings_menu', function ( $tabs ) {
$remove_names = array(
'gravityformsuserregistration',
);

foreach ( $tabs as $key => $tab ) {
if ( in_array( $tab['name'], $remove_names ) ) {
unset( $tabs[ $key ] );
}
}

return $tabs;
} );

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

gform_sendgrid_send_email_failed

gform_sendgrid_send_email_failed

DescriptionUsageParametersSinceSource Code

Description
Triggered when an email from Gravity Forms fails to be passed to SendGrid.
Usage
add_action( 'gform_sendgrid_send_email_failed', 'my_function', 10, 6 );

Parameters

$error_message string
The error message.

$sendgrid_email array
The SendGrid email arguments.

$email array
The original email details.

$message_format array
The message format, html or text.

$notification array
The Notification object.

$entry array
The current Entry object.

Since
This action hook was added in SendGrid version 1.4.
Source Code
This action hook is located in GF_SendGrid::maybe_send_email() in gravityformssendgrid/class-gf-sendgrid.php.

gform_sendgrid_email

gform_sendgrid_email

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
Allows the email being sent by SendGrid to be modified.
Usage
The following would apply to all forms:
1add_filter( 'gform_sendgrid_email', 'your_function_name', 10, 5 );
To target a specific form, append the form id to the hook name. (format: gform_sendgrid_email_FORMID)
1add_filter( 'gform_sendgrid_email_1', 'your_function_name', 10, 5 );
To target a specific feed for a form, append the form id and feed id to the hook name. (format: gform_sendgrid_email_FORMID_FEEDID)
1add_filter( 'gform_sendgrid_email_1_4', 'your_function_name', 10, 5 );

Parameters

$sendgrid_email array
The SendGrid email arguments.

$email array
The original email details.

$message_format string
The message format, html or text.

$notification Notification Object
The Notification object.

$entry Entry Object
The current entry.

Examples
123456add_filter( 'gform_sendgrid_email', 'change_sendgrid_email', 10, 5 );function change_sendgrid_email( $sendgrid_email, $email, $message_format, $notification, $entry ){        //add a CC email address    $sendgrid_email['personalizations'][0]['cc'][0]['email'] = '[email protected]';    return $sendgrid_email;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in SendGrid v1. Added $entry parameter in v2.
Source Code
This filter is located in GF_SendGrid::maybe_send_email() in gravityformssendgrid/class-gf-sendgrid.php.

gform_secure_file_download_url

gform_secure_file_download_url

DescriptionUsageParametersPlacementSinceSource Code

Description
Allows for manual filtering of the download URL to handle conditions such as unusual domain mapping and others.
Usage
The base filter which would run for all forms would be used like so:
add_filter( 'gform_secure_file_download_url', 'your_function_name', 10, 2 );

Parameters

$download_url string
The URL from which to download the 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.
Since
This filter was added in Gravity Forms 2.1.1.1.
Source Code
This filter is located in GF_Field_FileUpload::get_download_url() in includes/fields/class-gf-field-fileupload.php.

gform_secure_file_download_location

gform_secure_file_download_location

DescriptionUsageParametersExamplePlacementSource Code

Description
By default the real location of the uploaded file will be hidden. The download URL will be generated with a security token to prevent guessing or enumeration attacks to discover the location of other files.
Return FALSE to display the real location.
Not recommended – use with caution!
Usage
The following would apply to all forms.
add_filter('gform_secure_file_download_location', '__return_false');

Parameters

$secure_download_location bool
If the secure location should be used. Defaults to true.

$file string
The URL of the file.

$this GF_Field_Fileupload
The field.

Example
$secure_download_location = apply_filters( 'gform_secure_file_download_location_' . $this->formId, $secure_download_location, $file, $this );

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_secure_file_download_is_https

gform_secure_file_download_is_https

DescriptionUsageParametersPlacementSource Code

Description
Allows for override of SSL replacement.
By default Gravity Forms will attempt to determine if the schema of the URL should be overwritten for SSL. This is not ideal for all situations, particularly domain mapping. Setting $field_ssl to false will prevent the override.
Usage
The following would apply to all forms.
1add_filter( 'gform_secure_file_download_is_https', 'your_function_name', 10, 3 );

Parameters

$field_ssl bool
True to allow override if needed or false if not. Defaults to true.

$file_url string
The file URL in question.

$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_search_criteria_entry_list

gform_search_criteria_entry_list

DescriptionUsageParametersExamplesEntries created by the current userSinceSource Code

Description
Use this filter to modify search criteria used to retrieve entries for display on the Entry List page.
Usage
The following would apply to all forms.
add_filter( 'gform_search_criteria_entry_list', 'your_function_name' );

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_search_criteria_entry_list_FORMID)
add_filter( 'gform_search_criteria_entry_list_6', 'your_function_name' );

Parameters

$search_criteria array
An array containing the search criteria. The search criteria array is constructed as follows:
Filter by status:
$search_criteria['status'] = 'active';
Filter by any column in the main table:
$search_criteria['field_filters'][] = array( 'key' => 'currency', 'value' => 'USD' );
$search_criteria['field_filters'][] = array( 'key' => 'is_read', 'value' => true );
​$search_criteria['field_filters'][] = array( 'key' => 'created_by', 'value' => $current_user->ID );

Filter by date range:
$search_criteria['start_date'] = $start_date;
$search_criteria['end_date'] = $end_date;

Filter by Field Values:
$search_criteria['field_filters'][] = array( 'key' => '1', 'value' => 'gquiz159982170' );

Filter Operators:
// Supported operators for scalar values: is/=, isnot, contains
$search_criteria['field_filters'][] = array( 'key' => '1', 'operator' => 'contains', 'value' => 'Steve' );
// Supported operators for array values: in/=, not in/!=
$search_criteria['field_filters'][] = array( 'key' => '1', 'operator' => 'not in', 'value' => array( 'Alex', 'David', 'Dana' );

Filter by a checkbox value (not recommended):
$search_criteria['field_filters'][] = array( 'key' => '2.2', 'value' => 'gquiz246fec995' );

Note: this will work for checkboxes but it won』t work if the checkboxes have been re-ordered – best to use the following example below
Filter by a checkbox value (recommended):
$search_criteria['field_filters'][] = array( 'key' => '2', 'value' => 'gquiz246fec995' );
$search_criteria['field_filters'][] = array( 'key' => '2', 'operator' => 'not in', 'value' => array( 'First Choice', 'Third Choice' ) );

Filter by List Field Value:
The List field value is serialized, so you have to use the contains operator to search that field.
$search_criteria['field_filters'][] = array( 'key' => '15', 'operator' => 'contains', 'value' => 'Whatever' );

Filter by a global/free-form search of values of any form field:
$search_criteria['field_filters'][] = array( 'value' => $search_value );
// OR
$search_criteria['field_filters'][] = array( 'key' => 0, 'value' => $search_value );

Filter entries by Entry meta (added using the gform_entry_meta hook):
$search_criteria['field_filters'][] = array( 'key' => 'gquiz_score', 'value' => '1' );
$search_criteria['field_filters'][] = array( 'key' => 'gquiz_is_pass', 'value' => '1' );

Filter by ALL / ANY of the field filters:
$search_criteria['field_filters']['mode'] = 'all'; // default
$search_criteria['field_filters']['mode'] = 'any';

$form_id integer
The ID of the current form.

Examples
Entries created by the current user
The following example shows how you can configure the search to only return entries submitted by the current user.
add_filter( 'gform_search_criteria_entry_list', 'override_search_criteria' );
function override_search_criteria( $search_criteria ) {
$search_criteria['field_filters'][] = array( 'key' => 'created_by', 'operator' => 'is', 'value' => get_current_user_id() );

return $search_criteria;
}

Since
This filter was added in Gravity Forms 1.9.14.30.
Source Code
This filter is located in:
GFEntryList::leads_page() in entry_list.php
GFEntryDetail::lead_detail_page in entry_detail.php and print-entry.php

gform_savecontinue_link

gform_savecontinue_link

DescriptionUsageParametersExamplesChange to an image buttonPlacementSource Code

Description
Filters the save and continue link, allowing the tag to be customized.
Usage
The following would apply to all forms.
1add_filter( 'gform_savecontinue_link', 'your_function_name', 10, 2 );
The following would apply to form ID 3.
1add_filter( 'gform_savecontinue_link_3', 'your_function_name', 10, 2 );

Parameters

$save_button string
The string containing the save and continue link markup.

$form array
The Form object associated with the link.

Examples
Change to an image button
12345678add_filter( 'gform_savecontinue_link', function ( $save_button, $form ) {    $form_id            = $form['id'];    $button             = rgars( $form, 'save/button' );    $button['type']     = 'image';    $button['imageUrl'] = 'the/url/here';     return rgars( $form, 'save/enabled' ) ? GFFormDisplay::get_form_button( $form_id, "gform_save_{$form_id}_link", $button, rgar( $button, 'text' ), 'gform_save_link', rgar( $button, 'text' ), 0, "jQuery("#gform_save_{$form_id}"").val(1);"" ) : $save_button;}

gform_save_zapier_button

gform_save_zapier_button

DescriptionUsageParametersExamplesPlacementSource Code

Description
The 「gform_save_zapier_button」 filter allows the Zapier Feed save button to be modified.
Usage
1add_filter( 'gform_save_zapier_button', 'your_function_name', 10, 1 );

Parameters

$zapier_button string
The HTML rendered for the save button.

Examples
1234add_filter( 'gform_save_zapier_button', 'change_save_button', 10, 1 );function change_save_button( $zapier_button ){    return '';}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFZapier::zapier_edit_page() in gravityformszapier/zapier.php.

gform_save_field_value

gform_save_field_value

DescriptionUsageParametersExamples1. Encode all values2. Encode values for a specific form3. Process merge tags4. Uppercase Value5. Remove new lines, tabs and carriage returns6. Return the current date in your desired format7. Skip saving of Credit Card type and last four digits8. Make a value』s first character uppercasePlacementSource CodeSince

Description

Use this filter to change the field』s value before saving it to the database. Use in conjunction with gform_get_input_value to perform low level transformations, such as encrypting/decrypting a field.

Usage

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

add_filter( 'gform_save_field_value', 'your_function_name', 10, 5 );

To target a specific form append the form id to the hook name. (format: gform_save_field_value_FORMID)

add_filter( 'gform_save_field_value_10', 'your_function_name', 10, 5 );

To target a specific field append both the form id and the field id to the hook name. (format: gform_save_field_valuee_FORMID_FIELDID)

add_filter( 'gform_save_field_value_10_3', 'your_function_name', 10, 5 );

Parameters

$value string
The current entry value to be filtered.

$entry Entry Object
The current entry.

$field Field Object | null
The field from which the entry value was submitted or null if updating the entry and the field no longer exists.

$form Form Object
The form from which the entry value was submitted.

$input_id Mixed
The input ID of the input being saved. Defaults to the field ID for single input field types. Added in GF v1.8.5.8

Examples

1. Encode all values

This example base 64 encodes the field values. View gform_get_input_value for an example on how to decode the fields.

add_filter( 'gform_save_field_value', 'save_field_value', 10, 4 );
function save_field_value( $value, $lead, $field, $form ) {
return base64_encode( $value );
}

This example uses the GFCommon::encrypt() method.

add_filter( 'gform_save_field_value', 'save_field_value', 10, 4 );
function save_field_value( $value, $lead, $field, $form ) {
return GFCommon::encrypt( $value );
}

2. Encode values for a specific form

This is another example where you may select a specific form and specific fields to encode.

add_filter( 'gform_save_field_value', 'save_field_value', 10, 4 );
function save_field_value( $value, $lead, $field, $form ) {
//if not the form with fields to encode, just return the unaltered value without checking the fields
if ( ! is_object( $field ) || absint( $form->id ) <> 94 ) {
return $value;
}

//array of field ids to encode
$encode_fields = array( 1, 2, 3 );

//see if the current field id is in the array of fields to encode; encode if so, otherwise return unaltered value
if ( in_array( $field->id, $encode_fields ) ) {
return base64_encode( $value );
} else {
return $value;
}
}

3. Process merge tags

The following example shows how you can replace merge tags before saving the field value.

add_filter( 'gform_save_field_value', 'replace_merge_tags', 10, 4 );
function replace_merge_tags( $value, $entry, $field, $form ) {
$value = GFCommon::replace_variables( $value, $form, $entry );
return $value;
}

4. Uppercase Value

The following example shows how you can uppercase a field value when the entry is saved.

add_filter( 'gform_save_field_value', 'uppercase_text', 10, 3 );
function uppercase_text( $value, $entry, $field ) {
if ( $field->get_input_type() == 'text' ) {
$value = strtoupper( $value );
}

return $value;
}

5. Remove new lines, tabs and carriage returns

The following example shows how you can remove new lines, tabs and carriage returns before saving the field value.

add_filter("gform_save_field_value", "remove_n_t_r", 10, 4);
function remove_n_t_r($value, $entry, $field, $form){
$new_value = str_replace(array("n", "t", "r"), '', $value);
return $new_value;
}

6. Return the current date in your desired format

The following example will return current local date in Y-m-d format. Use PHP』s date format to customize date format to your like.

add_filter("gform_save_field_value", "current_date", 10, 4);
function current_date( $value, $entry, $field, $form ){
$local_timestamp = GFCommon::get_local_timestamp( time() );
$local_date = date_i18n( 'Y-m-d', $local_timestamp, true );

return $local_date;
}

7. Skip saving of Credit Card type and last four digits

To be compliant with PCI standards, only the card type and last four digits are stored. The following example can be used to not store this information either.

add_filter( 'gform_save_field_value', 'gf_empty_card_field', 10, 4 );
function gf_empty_card_field( $value, $lead, $field, $form ) {
if ( $field->type === 'creditcard' || $field->type === 'stripe_creditcard' ){
$value = false;
}
return $value;
}

8. Make a value』s first character uppercase

The following example shows how you can uppercase only the first character of a field value when the entry is saved. This time we』re limiting the snippet scope by adding the form id (540) and field id (3) to the filter name.

// Change 540 to your form id number, and 3 to your field id.
add_filter( 'gform_save_field_value_540_3', 'gf_uppercase_first_character', 10, 4 );
function gf_uppercase_first_character( $value, $lead, $field, $form ) {
$value = ucfirst( $value );
GFCommon::log_debug( __METHOD__ . '(): Modififed value => ' . $value );
return $value;
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

gf_apply_filters( 'gform_save_field_value', array( $form['id'], $field->id ), $value, $lead, $field, $form, $input_id )

This filter is located in the following methods in forms_model.php

GFFormsModel::get_prepared_input_value()GFFormsModel::update_lead_field_value()

Since

The base filter was added in Gravity Forms 1.5. The form and field specific versions were added in Gravity Forms 1.9.13.6