gform_save_and_continue_resume_url

gform_save_and_continue_resume_url

DescriptionUsageParametersExamples1. Override the resume url2. Remove query arguments from url3. Require loginPlacementSource Code

Description
Use this filter to change the resume link generated when an incomplete submission is saved.
Usage
add_filter( 'gform_save_and_continue_resume_url', 'your_function_name', 10, 4 );

Parameters

$resume_url string
The current resume url.

$form Form Object
The form that is currently being processed.

$token string
The unique token generated when the incomplete submission was saved.

$email string
The email the resume link will be sent to.

Examples
1. Override the resume url
This example shows how you can change the resume url.
add_filter( 'gform_save_and_continue_resume_url', function( $resume_url, $form, $token, $email ) {

return str_replace( 'http:', 'https:', $resume_url );
}, 10, 4 );

2. Remove query arguments from url
add_filter( 'gform_save_and_continue_resume_url', function( $resume_url, $form, $token, $email ) {

// remove specific query arg
//$resume_url = remove_query_arg( array( 'boom' ), $resume_url );

// remove ALL query args
$resume_url = add_query_arg( array( 'gf_token' => $token ), array_shift( explode( '?', $resume_url ) ) );

return $resume_url;
}, 10, 4 );

3. Require login
add_filter( 'gform_save_and_continue_resume_url', function( $resume_url ) {
return wp_login_url( $resume_url );
} );

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

gform_sanitize_confirmation_message

gform_sanitize_confirmation_message

DescriptionUsageParametersExamplesTurn on sanitizationPlacementSinceSource Code

Description
The 「gform_sanitize_confirmation_message」 filter in Gravity Forms is used to sanitize the complete confirmation message just before outputting to the page. All scripts will be removed.
By the time the confirmation is displayed all the field values have been sanitized. However, there may be situations which require and additional level of sanitization. For example, this filter is useful if you』re using merge tags as values for HTML attributes.
Usage
add_filter( 'gform_sanitize_confirmation_message', 'your_function_name' );

Parameters

$sanitize_confirmation_nessage bool
The confirmation message. Default: false.

Examples
Turn on sanitization
add_filter( 'gform_sanitize_confirmation_message', '__return_true' );

Placement
Your code snippet should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms 2.0.
Source Code
This filter is located in GFCommon::maybe_sanitize_confirmation_message() in common.php.

gform_rule_pre_evaluation

gform_rule_pre_evaluation

DescriptionUsageJavaScript VersionParametersExamplePlacementSinceSource CodePHP VersionParametersExamplePlacementSinceSource Code

Description
The gform_rule_pre_evaluation filters can be used to modify a conditional logic rule before it is evaulated.
Usage
The gform_rule_pre_evaluation filter has both a JavaScript version and a PHP version. Both versions should be used.
The JavaScript version only overrides the conditional logic rule on the front-end.
12345gform.addFilter( 'gform_rule_pre_evaluation', function( rule, formId, conditionalLogic ) {    // Modify the rule.     return rule;} );
The PHP version overrides the conditional logic rule when it is evaulated during and post submission.
12345add_filter( 'gform_rule_pre_evaluation', function(  $rule, $form, $logic, $field_values, $entry ) {    // Modify the rule.     return $rule;}, 10, 5 );
JavaScript Version

Parameters

rule Javascript Object
The current rule object. e.g.
12345{  "fieldId": "1",  "operator": "isnot",  "value": ""}

formId integer|string
The ID of the form in use.

conditionalLogic Javascript Object
The current conditional logic object. e.g.
12345678910111213141516{  "actionType": "show",  "logicType": "all",  "rules": [    {      "fieldId": "1",      "operator": "isnot",      "value": ""    },    {      "fieldId": "1",      "operator": "is",      "value": "{:1}"    }  ]}

Example
This example shows how you can replace field merge tags used in the conditional logic rule value.
12345678910gform.addFilter( 'gform_rule_pre_evaluation', function( rule, formId ) {    var mergeTags = GFMergeTag.parseMergeTags( rule.value );    if ( ! mergeTags.length ) {        return rule;    }     rule.value = GFMergeTag.getMergeTagValue( formId, mergeTags[0][1], mergeTags[0][3] );     return rule;} );
Placement
Your code snippet can be placed in a HTML field on your form or in a theme custom JavaScript file.
Since
This filter was added in Gravity Forms v2.4.22.
Source Code
This filter is located in js/conditional_logic.js
PHP Version

Parameters

$rule array
The current rule object. See the Rule Properties section of the Conditional Logic Object article.

$form Form Object
The form currently being processed.

$logic Conditional Logic Object
The conditional logic.

$field_values array
An array of dynamic population parameter keys with their corresponding values to be populated.

$entry Entry Object
The entry currently being processed, if available.

Example
This example shows how you can replace field merge tags used in the conditional logic rule value.
12345678910111213add_filter( 'gform_rule_pre_evaluation', 'filter_gform_rule_pre_evaluation', 10, 5 );function filter_gform_rule_pre_evaluation( $rule, $form, $logic, $field_values, $entry ) {    if ( ! empty( $rule['value'] ) && strpos( $rule['value'], '{' ) !== false ) {        remove_filter( 'gform_rule_pre_evaluation', 'filter_gform_rule_pre_evaluation' );        if ( empty( $entry ) ) {            $entry = GFFormsModel::get_current_lead();        }        $rule['value'] = GFCommon::replace_variables( $rule['value'], $form, $entry, false, false, false, 'text' );        add_filter( 'gform_rule_pre_evaluation', 'filter_gform_rule_pre_evaluation', 10, 5 );    }     return $rule;}
Note: In this example field merge tags are being processed before the entry has been saved so GFFormsModel::get_current_lead() is used to get a mock entry object for the current submission and GFCommon::replace_variables() is used to process the merge tags. Both of these methods can trigger the evaulation of conditional logic which will trigger this filter. To prevent a recursion related fatal error you must remove your hooked function before calling those methods and restore it after.
Placement
Your code snippet 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.4.22.
Source Code
This filter is located in GFFormsModel::evaluate_conditional_logic() in forms_model.php

gform_routing_field_types

gform_routing_field_types

DescriptionUsageParametersExamplePlacementSource Code

Description
The 「gform_routing_field_types」 filter in Gravity Forms allows the field types supported by notification routing to be modified.
Usage
The following would apply to all forms.
1add_filter( 'gform_routing_field_types', 'your_function_name' );

Parameters

$field_types array
Currently supported field types. Generated from GFNotification::$supported_fields

Example
1234add_filter( 'gform_routing_field_types', function( $field_types ) {array_push( $field_types, 'my-custom-field-type' );  return $field_types;} );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in notification.php

gform_rich_text_editor_options

gform_rich_text_editor_options

DescriptionUsageParametersExamples1. Set a custom height value2. Enable the Add Media buttonSource Code

Description
The 「gform_rich_text_editor_options」 filter in Gravity Forms allows the rich text editor options to be modified. A specific FORMID or FORMID + FIELDID may also be used with the hook.
Usage
Applies to all forms:
add_filter( 'gform_rich_text_editor_options', 'my_function', 10, 4 );

Targets a specific form:
add_filter( 'gform_rich_text_editor_options_3', 'my_function', 10, 4 );

Targets a specific field for a specific form:
add_filter( 'gform_rich_text_editor_options_3_6', 'my_function', 10, 4 );

Parameters

$editor_settings array
Array of buttons to include within the TinyMCE editor inside Gravity Forms.
Defaults to the following:
array(
'textarea_name' => 'input_' . $id,
'wpautop' => true,
'editor_class' => $class,
'textarea_rows' => 10,
'tabindex' => $tabindex,
'media_buttons' => false,
'quicktags' => false,
'tinymce' => array( 'init_instance_callback' => 'function...' ),
);

$field_object object
The full field object returned.

$form array
The form that the filter is being run on.

$entry array
The entry, if available.

Examples
1. Set a custom height value
function my_function( $editor_settings, $field_object, $form, $entry ) {
$editor_settings['editor_height'] = 400;
return $editor_settings;
}
add_filter( 'gform_rich_text_editor_options', 'my_function', 10, 4 );

2. Enable the Add Media button
This will add the Add Media button before the toolbar just like WP does in Post/Page editor. The user must be logged in to see the button; this is a WordPress requirement not a Gravity Forms limitation.
function show_media_button( $editor_settings, $field_object, $form, $entry ) {
$editor_settings['media_buttons'] = true;
return $editor_settings;
}
add_filter( 'gform_rich_text_editor_options', 'show_media_button', 10, 4 );

Source Code
This filter is located in class-gf-field-textarea.php.

gform_rich_text_editor_buttons

gform_rich_text_editor_buttons

DescriptionUsageParametersExamplesFiltering additional button rowsSource Code

Description
The 「gform_rich_text_editor_buttons」 filter in Gravity Forms controls the buttons displayed in the first row within the Gravity Forms rich text editor. This hook may be filtered by FORMID or by FORMID + FIELDID.
Usage
Applies to all forms:
add_filter( 'gform_rich_text_editor_buttons', 'my_function', 10, 2 );

To target a specific form append the form id to the hook name. (format: gform_rich_text_editor_buttons_FORMID)
add_filter( 'gform_rich_text_editor_buttons_2', 'my_function', 10, 2 );

To target a specific form field append the form id and field id to the hook name. (format: gform_rich_text_editor_buttons_FORMID_FIELDID)
add_filter( 'gform_rich_text_editor_buttons_2_6', 'my_function', 10, 2 );

Parameters

$mce_buttons array
Array of buttons to include within the TinyMCE editor inside Gravity Forms.

array( 'formatselect', 'bold', 'italic', 'bullist', 'numlist', 'blockquote', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'spellchecker' );
Note: Spell Checker button was removed from WP core since version 3.6; you need to install a third-party plugin if you want to use it, e.g. TinyMCE Spellcheck.

$editor_id string
The HTML element ID for the field using the rich text editor.

$field_object object
Object containing information about the field.

Examples
This example shows how you can add another button.
add_filter( 'gform_rich_text_editor_buttons', 'my_function', 10, 2 );
function my_function( $mce_buttons ) {
$mce_buttons[] = 'wp_more';
return $mce_buttons;
}

This example shows how you can remove the majority of the buttons.
add_filter( 'gform_rich_text_editor_buttons', 'my_function', 10, 2 );
function my_function( $mce_buttons ) {
$mce_buttons = array( 'bold', 'italic', 'bullist' );
return $mce_buttons;
}

The following will apply for all fields with the rich text editor enabled in a form with id 2.
add_filter( 'gform_rich_text_editor_buttons_2', 'my_function', 10, 2 );
function my_function() {
$mce_buttons = array( 'bold', 'italic', 'bullist' ); // Enable only Bold, Italic and Bullet List buttons
return $mce_buttons;
}

Filtering additional button rows
Gravity Forms also makes filters available to control the display of buttons in rows two through four of the rich text editor:

gform_rich_text_editor_buttons_row_two
gform_rich_text_editor_buttons_row_three
gform_rich_text_editor_buttons_row_four

These filters can be used in the exact same way as the usage examples for the gform_rich_text_editor_buttons filter above but they allow you to filter additional rows in the rich text editor. Which row is filtered is noted in the filter name.
By default WordPress includes buttons in the first and second row of the TinyMCE editor, but other components in your site』s setup could include buttons in the third and fourth row including via these filters.
Source Code
This filter hook is located in class-gf-field-textarea.php.

gform_rich_text_editor_buttons_row_two

gform_rich_text_editor_buttons_row_two

DescriptionUsageParametersSource Code

Description
The 「gform_rich_text_editor_buttons_row_two」 filter in Gravity Forms controls the buttons displayed in the second row within the Gravity Forms rich text editor.
For more specific use case examples please see our documentation for the gform_rich_text_editor_buttons parent filter.
Usage
Applies to all forms:
1add_filter( 'gform_rich_text_editor_buttons_row_two', 'my_function', 10, 2 );
To target a specific form append the form id to the hook name. (format: gform_rich_text_editor_buttons_row_two_FORMID)
1add_filter( 'gform_rich_text_editor_buttons_row_two_2', 'my_function', 10, 2 );
To target a specific form field append the form id and field id to the hook name. (format: gform_rich_text_editor_buttons_row_two_FORMID_FIELDID)
1add_filter( 'gform_rich_text_editor_buttons_row_two_2_6', 'my_function', 10, 2 );
Parameters

$mce_buttons array
Array of second row buttons to include within the TinyMCE editor inside Gravity Forms.

1array( 'strikethrough', 'hr', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' );

$editor_id string
The HTML element ID for the field using the rich text editor.

$field_object object
Object containing information about the field.

Source Code
This filter hook is located in class-gf-field-textarea.php.

gform_rich_text_editor_buttons_row_three

gform_rich_text_editor_buttons_row_three

DescriptionUsageParametersSource Code

Description
The 「gform_rich_text_editor_buttons_row_three」 filter in Gravity Forms controls the buttons displayed in the third row within the Gravity Forms rich text editor. Note: WordPress and Gravity Forms do not include any buttons on the third row of the rich text editor by default.
For more specific use case examples please see our documentation for the gform_rich_text_editor_buttons parent filter.
Usage
Applies to all forms:
add_filter( 'gform_rich_text_editor_buttons_row_three', 'my_function', 10, 2 );

To target a specific form append the form id to the hook name. (format: gform_rich_text_editor_buttons_row_three_FORMID)
add_filter( 'gform_rich_text_editor_buttons_row_three_2', 'my_function', 10, 2 );

To target a specific form field append the form id and field id to the hook name. (format: gform_rich_text_editor_buttons_row_three_FORMID_FIELDID)
add_filter( 'gform_rich_text_editor_buttons_row_three_2_6', 'my_function', 10, 2 );

Parameters

$mce_buttons array
Array (empty by default) of third row buttons to include within the TinyMCE editor inside Gravity Forms.

$editor_id string
The HTML element ID for the field using the rich text editor.

$field_object object
Object containing information about the field.

Source Code
This filter hook is located in class-gf-field-textarea.php.

gform_rich_text_editor_buttons_row_four

gform_rich_text_editor_buttons_row_four

DescriptionUsageParametersSource Code

Description

The 「gform_rich_text_editor_buttons_row_four」 filter in Gravity Forms controls the buttons displayed in the fourth row within the Gravity Forms rich text editor. Note: WordPress and Gravity Forms do not include any buttons on the fourth row of the rich text editor by default.

For more specific use case examples please see our documentation for the gform_rich_text_editor_buttons parent filter.

Usage

This section shows different usage formats, and includes a small example of each.

Applies to all forms:

add_filter( 'gform_rich_text_editor_buttons_row_four', 'my_function', 10, 2 );

To target a specific form, append the form id to the hook name.

gform_rich_text_editor_buttons_row_four_FORMID

add_filter( 'gform_rich_text_editor_buttons_row_four_2', 'my_function', 10, 2 );

To target a specific form field, append the form id and field id to the hook name.

gform_rich_text_editor_buttons_row_four_FORMID_FIELDID

add_filter( 'gform_rich_text_editor_buttons_row_four_2_6', 'my_function', 10, 2 );

Parameters

ParameterTypeDescription$mce_buttonsarrayArray (empty by default) of fourth row buttons to include within the TinyMCE editor inside Gravity Forms.$editor_id stringThe HTML element ID for the field using the rich text editor.$field_objectobjectObject containing information about the field.

Source Code

This filter hook is located in class-gf-field-textarea.php.

gform_rfc_url_validation

gform_rfc_url_validation

DescriptionUsageParametersExamplesPlacementSource Code

Description
Enables and disables RFC URL validation. Defaults to true. When RFC is enabled, URLs will be validated against the RFC standard. When disabled, a simple and generic URL validation will be performed.
Usage
add_filter( 'gform_rfc_url_validation', '__return_false', 10, 1 );

Parameters
Defaults to true. Set to false using __return_false or a custom function to set to false, to disable RFC.
Examples
add_filter( 'gform_rfc_url_validation', '__return_false', 10, 1 );

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