gform_tooltips

gform_tooltips

DescriptionUsageParametersExamplesSource Code

Description
This filter is executed before any Gravity Form admin page is loaded. It can be used to change existing tooltips or add new ones (adding new tooltips is useful when developing add-ons for Gravity Forms).
Usage
add_filter( 'gform_tooltips', 'add_tooltips' );

Parameters

$tooltips array
An array with the existing tooltips. It is an associative array where the key is the tooltip name and the value is the tooltip.
$tooltips['some_new_feature'] = 'Help text for the new feature goes here';

Examples
This example adds 3 new tooltips to the list.
add_filter( 'gform_tooltips', 'add_tooltips' );
function add_tooltips( $tooltips ) {
$tooltips['feature_1'] = 'Tooltip for feature 1';
$tooltips['feature_2'] = 'Tooltip for feature 2';
$tooltips['feature_3'] = 'Tooltip for feature 3';
return $tooltips;
}

Source Code
This filter is located in gform_tooltip() in tooltips.php.

gform_toolbar_menu

gform_toolbar_menu

DescriptionUsageParametersExamplesSource Code

Description
Modify the links which display in the Gravity Forms toolbar.
Usage
1add_filter( 'gform_toolbar_menu', 'my_custom_function' );
Parameters

$menu_items array
An array of menu items and their properties.

$form_id integer
The ID of the form for which the toolbar is being displayed.

Examples
This example demonstrates how you can add your own item to the Gravity Forms Toolbar which displays on the Form Editor, Form Settings, and Entries views.
123456789101112131415add_filter( 'gform_toolbar_menu', 'my_custom_toolbar', 10, 2 );function my_custom_toolbar( $menu_items, $form_id ) {     $menu_items['my_custom_link'] = array(        'label' => 'My Custom Link', // the text to display on the menu for this link        'title' => 'My Custom Link', // the text to be displayed in the title attribute for this link        'url' => self_admin_url( 'admin.php?page=my_custom_page&id=' . $form_id ), // the URL this link should point to        'menu_class' => 'gf_form_toolbar_custom_link', // optional, class to apply to menu list item (useful for providing a custom icon)        'link_class' => rgget( 'page' ) == 'my_custom_page' ? 'gf_toolbar_active' : *, // class to apply to link (useful for specifying an active style when this link is the current page)        'capabilities' => array( 'gravityforms_edit_forms' ), // the capabilities the user should possess in order to access this page        'priority' => 500 // optional, use this to specify the order in which this menu item should appear; if no priority is provided, the menu item will be append to end    );     return $menu_items;}
Source Code
This filter is located in GFForms::top_toolbar() in gravityforms.php

gform_temp_file_expiration_days

gform_temp_file_expiration_days

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
The gform_temp_file_expiration_days filter can be used to override the number of days before temporary file uploads are deleted.
Usage
add_filter( 'gform_temp_file_expiration_days', 'your_function_name' );

Parameters

$expiration_days int
The number of days temporary files should remain in the uploads directory. Default is 2 or 30 if save and continue is enabled.

$form Form Object
The form currently being processed.

Example
add_filter( 'gform_temp_file_expiration_days', 'temp_file_expiration_days' );
function temp_file_expiration_days( $expiration_days ) {
$expiration_days = 90;
return $expiration_days;
}

Placement
This code should be placed in the functions.php file of your active theme, or within its own plugin.
Since
This filter was added in Gravity Forms 2.1.3.5.
Source Code
This filter is located in GFFormDisplay::clean_up_files() in forms_model.php.

gform_target_page

gform_target_page

DescriptionUsageParametersExamplesSinceSource Code

Description
The 「gform_target_page」 filter in Gravity Forms sets the target page when submitting the form. Typically applies to multi-page forms.
Usage
Apply to all forms.
add_filter( 'gform_target_page', 'my_function', 10, 2 );

Target a specific form.
add_filter( 'gform_target_page_123', 'my_function', 10, 2 );

Parameters

$target_page integer
The target page number.

$form Form Object
The current Form object.

$current_page integer
The page from which the form was submitted.

$field_values array
Dynamic population values that were provided when loading the form.

Examples
This example (from the 3rd party GP Multi-page Navigation plugin) demonstrates how you can account for conditional padding that is added to the target page number when jumping from a source page to a target page with one or more conditional pages between them.
add_filter( 'gform_target_page', 'adjust_target_page_for_conditional_logic', 10, 2 );
function adjust_target_page_for_conditional_logic( $modified_target_page, $form ) {

$target_page = rgpost( 'gform_target_page_number_' . $form['id'] );
$source_page = rgpost( 'gform_source_page_number_' . $form['id'] );

// if we are not submitting the form ($target_page == 0) and if we are
// navigating more than one page from the current page in either
// direction, we're safe.
$forward_skip = $target_page > $source_page + 1;
$back_skip = $target_page < $source_page - 1; if( $target_page == 0 || ( ! $forward_skip && ! $back_skip ) ) { return $modified_target_page; } // GF is trying to submit the form incorrectly; this often occurs when // you target the last page of a form and there are one or more conditionally // hidden pages between the source page and the target page. if( $forward_skip && $modified_target_page == 0 ) { $target_page = GFFormDisplay::get_max_page_number( $form ); } return $target_page; } Since This hook was added in Gravity Forms 2.1.2.13. Source Code This filter is located in the GFFormDisplay::get_target_page() method in /form_display.php.

gform_tabindex

gform_tabindex

DescriptionAccessibility ImpactsUsageParametersExamplesPlacementSource Code

Description
This filter is executed before the first field is displayed on the form. It can be used to change the tabindex start value or to disable the tabindex attribute.
Accessibility Impacts
Please note that changing the tabindex has accessibility implications. You can unintentionally upset the logical tabindex order determined by the browser when the page is loaded which can affect usability.
If your goal is to meet required accessibility guidelines, we highly discourage the use of this filter and recommend letting the user』s browser determine the tabindex of your page.
Usage
Applies to all forms.
add_filter( 'gform_tabindex', '__return_false' );

Applies to a specific form. In this case, form Id 5.
add_filter( 'gform_tabindex_5', '__return_false' );

Parameters

$tabindex string
The current tabindex.

$form Form Object
The current form.

Examples
This example changes form 10』s tabindex start value to 4
add_filter( 'gform_tabindex_10', 'change_tabindex' , 10, 2 );
function change_tabindex( $tabindex, $form ) {
return 4;
}

This example disable tabindex for all forms
add_filter( 'gform_tabindex', '__return_false' );

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

gform_system_status_page_SUBVIEW

gform_system_status_page_SUBVIEW

DescriptionUsageParametersChangelogPlacementSource Code

Description
Adds additional pages to the System Status menu.
Usage
add_action( 'gform_system_status_page_report', 'your_function_name' );

Parameters

$subview string
Used to complete the action name, allowing an additional subview to be detected.

Changelog

2.2: Introduced.

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

gform_system_status_menu

gform_system_status_menu

DescriptionUsageParametersSincePlacementSource Code

Description
Modify menu items which will appear in the System Status menu.
Usage
1add_filter( 'gform_system_status_menu', 'your_function_name' );

Parameters

$subviews array
An array of menu items to be displayed on the System Status page.

Since
This filter was added in 2.2.
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in system_status.php.

gform_system_report

gform_system_report

DescriptionUsageParametersSincePlacementSource Code

Description
The 「gform_system_report」 filter allows the sections displayed on the System Status page to be modified. Sections may be added/removed with the displayed text changed.
Usage
1add_filter( 'gform_system_report', 'your_function_name' );

Parameters

$system_report array
An array of default sections displayed on the System Status page.

Since
This filter was added in 2.2.
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in system_report.php.

gform_suppress_confirmation_redirect

gform_suppress_confirmation_redirect

DescriptionUsageParametersPlacementSinceSource Code

Description
Use this filter to suppress the default page or redirect confirmation type behavior after submission. This can be especially helpful if you are attempting to override the default behavior of these confirmation types such as opening the redirect in a new tab similar to the following example in our documentation using gform_confirmation.
Usage
The following would apply to all forms:
add_filter( 'gform_suppress_confirmation_redirect', '__return_true' );

Parameters

$suppress_redirect bool
Indicates whether the confirmation redirect header should be suppressed. Defaults to false.

Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 2.3.
Source Code
This filter is located in the following methods in form_display.php:

GFFormDisplay::process_form()
GFFormDisplay::handle_confirmation()

This filter is also located in the following methods in api.php:

GFAPI::submit_form()

gform_subscription_canceled

gform_subscription_canceled

DescriptionUsageParametersExamples1. Run Custom Function2. Downgrade User Role3. Mailchimp – Unsubscribe MemberPlacementSource Code

Description
This action hook can be used to perform custom actions when a subscription has been canceled.
Usage
add_action( 'gform_subscription_canceled', 'your_function_name', 10, 3 );

or
add_action( 'gform_subscription_cancelled', 'your_function_name', 10, 3 );

Parameters

$entry Entry Object
The entry from which the canceled subscription was originally generated.

$feed Feed Object
The feed from which the subscription was originally generated.

$transaction_id string
The transaction ID of the canceled subscription.

Examples
1. Run Custom Function
This example shows how to update your order on a fictional third party order fulfillment service.
add_action( 'gform_subscription_canceled', 'remove_user_privileges', 10, 3 );
function remove_user_privileges( $entry, $feed, $transaction_id ) {
global $wpdb;

// get user id by querying for the entry id in the user meta
$sql = $wpdb->prepare( "select user_id from wp_usermeta where meta_key = 'entry_id' and meta_value = {$entry['id']}" );
$user_id = $wpdb->get_var( $sql );

// if the User Registration plugin is active, you can use the GFUserData::get_user_by_entry_id() to retrieve the user from the entry ID
// $user = GFUserData::get_user_by_entry_id( $entry['id'] );

// use function to remove privileges for a user from a fictional third party application
mtp_remove_privileges( $user_id, $transaction_id );
}

2. Downgrade User Role
This example shows how you can downgrade the user role when a subscription is canceled via one of the credit card based payment add-ons.
Note: This code requires User Registration version 3.0+.
add_action( 'gform_subscription_canceled', 'downgrade_user_role', 10, 2 );
function downgrade_user_role( $entry, $feed ) {
if ( rgar( $feed, 'addon_slug' ) != 'gravityformspaypal' && function_exists( 'gf_user_registration' ) ) {
$user = gf_user_registration()->get_user_by_entry_id( $entry['id'] );
if ( ! empty( $user ) && ! is_wp_error( $user ) ) {
$user->set_role( 'pastsubscriber' );
}
}
}

3. Mailchimp – Unsubscribe Member
This example shows how you can unsubscribe a member from a Mailchimp list when the subscription is canceled. This example requires Gravity Forms Mailchimp add-on version 4.0 or greater. It also requires that the entry which created the subscription was the same entry which subscribed the user to the Mailchimp list.
add_action( 'gform_subscription_canceled', function ( $entry ) {
if ( ! class_exists( 'GF_MailChimp_API' ) ) {
// Abort if the class for interacting with the Mailchimp API is not available.
return;
}

// Get the Mailchimp feed which processed the entry and the Mailchimp API key.
$feeds = gf_mailchimp()->get_feeds_by_entry( $entry['id'] );
$api_key = gf_mailchimp()->get_plugin_setting( 'apiKey' );

if ( ! $feeds || rgblank( $api_key ) ) {
// Abort if the entry was not processed by a MailChimp feed or if the API key is empty.
return;
}

// Get the IDs of the Mailchimp list and the form field containing the email.
$feed = gf_mailchimp()->get_feed( $feeds[0] );
$list_id = rgars( $feed, 'meta/mailchimpList' );
$email_id = rgars( $feed, 'meta/mappedFields_EMAIL' );

if ( rgblank( $list_id ) || rgblank( $email_id ) ) {
// Abort if the list or email field ID are missing.
return;
}

// Get the email field value.
$form = GFAPI::get_form( $entry['form_id'] );
$email = gf_mailchimp()->get_field_value( $form, $entry, $email_id );

try {

// Get the member info for the specified email and list.
$mc_api = new GF_MailChimp_API( $api_key );
$member = $mc_api->get_list_member( $list_id, $email );

// Update the member status.
$member['status'] = 'unsubscribed';
$mc_api->update_list_member( $list_id, $member['email_address'], $member );
gf_mailchimp()->log_debug( "gform_subscription_canceled: member status for {$email} updated to unsubscribed." );

} catch ( Exception $e ) {
// Abort if an error occurred when interacting with the MailChimp API.
return;
}
} );

Placement
This code should be placed in the functions.php file of your active theme.
Source Code
do_action( 'gform_subscription_canceled', $entry, $feed, $transaction_id );
This action hook is located in GFPaymentAddOn::cancel_subscription() in includes/addon/class-gf-payment-addon.php.