gform_display_add_form_button

gform_display_add_form_button

DescriptionUsageParametersExamplesPlacementSource Code

Description
By default, the 「Add Form」 button will only be displayed on the Post or Page edit screens. Use this filter to allow the 「Add Form」 button to be displayed on other pages.
Note: The 「Add Form」 button requires a TinyMCE input, so in order to display it, you must first include a TinyMCE input to your page.
Usage
add_filter( 'gform_display_add_form_button', 'display_form_button_on_custom_page' );

Parameters

$is_post_edit_page bool
True if the current page is a Post or Page edit page. False otherwise.
$is_post_edit_page = in_array( RG_CURRENT_PAGE, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php', 'customize.php' ) );

Examples
This example enables the 「Add Form」 button on a custom page whose URL contains the following query string: 「page=my_page」.
add_filter( 'gform_display_add_form_button', 'display_form_button_on_custom_page' );
function display_form_button_on_custom_page( $is_post_edit_page ) {
if ( isset( $_GET['page'] ) && $_GET['page'] == 'my_page' ) {
return true;
}

return $is_post_edit_page;
}

Simple example to disable button.
add_filter( 'gform_display_add_form_button', '__return_false' );

This example enables the 「Add Form」 button if the page is not a post page.
add_filter( 'gform_display_add_form_button', function ( $is_post_edit_page ) {
global $current_screen;

return $current_screen instanceof WP_Screen && $current_screen->base != 'post' ? true : $is_post_edit_page;
} );

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

gform_disable_view_counter

gform_disable_view_counter

DescriptionUsageParametersExamples1. Disable for all forms2. Enable for a specific form3. Disable for a specific ipPlacementSource CodeSince

Description
This filter can be used to prevent the forms view counter being incremented. The views column will remain displayed on the Forms page.
Usage
The following would apply to all forms.
1add_filter( 'gform_disable_view_counter', '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_disable_view_counter_FORMID)
1add_filter( 'gform_disable_view_counter_5', 'your_function_name' );

Parameters

$view_counter_disabled bool
Is the view counter disabled. Default false.

Examples
1. Disable for all forms
1add_filter( 'gform_disable_view_counter', '__return_true' );
2. Enable for a specific form
1add_filter( 'gform_disable_view_counter_12', '__return_false' );
3. Disable for a specific ip
12345678add_filter( 'gform_disable_view_counter', 'disable_view_count_by_ip' );function disable_view_count_by_ip( $view_counter_disabled ) {   if ( GFFormsModel::get_ip() == 'SOMEIP' ) {        return true;   }    return $view_counter_disabled;}
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
Since
This filter was added in Gravity Forms 1.8.17.

gform_disable_registration

gform_disable_registration

DescriptionUsageParametersExamplesSource Code

Description
The 「gform_disable_registration」 filter allows add-ons to prevent the User Registration add-on from registering/updating a user.
Usage
Applies to all forms.
1add_filter( 'gform_disable_registration', 'your_function_name', 10, 3 );

Parameters

$is_disabled bool
True or false.

$form Form Object
The submitted form object.

$entry Entry Object
The entry object from which the user was registered.

$fulfilled bool
True or false. This may be a value passed from an add-on like PayPal which indicates that the payment has been fulfilled. Null as of version 3.0.

Examples
Below is an example which disables registration based on submitted form values.
123456789101112131415add_filter( 'gform_disable_registration', 'disable_registration', 10, 3 );function disable_registration( $is_disabled, $form, $entry ) {    //check form id and if not the form being checked simply status passed in to function    if ( $form['id'] != 160 ) {        return $is_disabled;    }     //check submitted values to decide if registration should be stopped    if ( rgar( $entry, '4' ) == 'No' && rgar( $entry, '5' ) == 'No' ) {        //disable registration        return true;    } else {        return false;    }}
Source Code
1$disable_registration = apply_filters( 'gform_disable_registration', false, $form, $entry, null /* $fullfilled deprecated */ );
This filter is located in GF_User_Registration::process_feed() in class-gf-user-registration.php.

gform_disable_print_form_scripts

gform_disable_print_form_scripts

DescriptionUsageParametersExamples1. Disable printing of scripts and stylesheets for all forms2. Target a specific formPlacementSinceSource Code

Description
This filter can be used to prevent scripts and stylesheets being printed when GFCommon::gform_do_shortcode() processes form shortcodes located in various form settings and confirmations after headers have been sent. Scripts and stylesheets would be enqueued instead.
Usage
The following would apply to all forms.
add_filter( 'gform_disable_print_form_scripts', 'your_function_name' );

Parameters

$disable_print_form_script bool
Should printing of the scripts and stylesheets be disabled? Default is false.

$form Form Object
The form object for the shortcode being processed.

$is_ajax bool
Indicates if ajax was enabled on the shortcode.

Examples
1. Disable printing of scripts and stylesheets for all forms
add_filter( 'gform_disable_print_form_scripts', '__return_true' );

2. Target a specific form
add_filter( 'gform_disable_print_form_scripts', 'disable_print_form_scripts', 10, 2 );
function disable_print_form_scripts( $disable_print_form_script, $form) {
if ( $form['id'] == 10 ) {
return true;
}

return $gform_disable_print_form_scripts;
}

Placement
This code 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::gform_do_shortcode() in common.php.

gform_disable_post_creation

gform_disable_post_creation

DescriptionUsageParametersExamples1. Disable for all forms2. Disable based on a field valuePlacementSource Code

Description
Use this filter to disable post creation when submitting a Gravity Form.

Note: This filter is intended for use with Gravity Forms built-in Post creation feature, it doesn』t support the Advanced Post Creation add-on.

Usage
1add_filter( 'gform_disable_post_creation', 'disable_post_creation', 10, 3 );
You can also specify this per form by adding the form id after the hook name.
1add_filter( 'gform_disable_post_creation_6', 'disable_post_creation', 10, 3 );
Parameters

$is_disabled bool
Variable to be filtered. Set it to true to prevent posts from being created.

$form Form Object
Current form.

$entry Entry Object
Current Entry array.

Examples
1. Disable for all forms
This example disables the post creation process for all forms:
1234add_filter( 'gform_disable_post_creation', 'disable_post_creation', 10, 3 );function disable_post_creation( $is_disabled, $form, $entry ) {    return true;}
2. Disable based on a field value
12345add_filter( 'gform_disable_post_creation_6', 'disable_post_creation', 10, 3 );function disable_post_creation( $is_disabled, $form, $entry ) {    $is_disabled = rgar( $entry, '2' ) != 'something' ? true : $is_disabled;    return $is_disabled;}
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFCommon::create_post() in common.php.

gform_disable_notification

gform_disable_notification

DescriptionUsageParametersExamples1. Disable ALL Notifications2. Disable a notification based on a field3. Update from gform_disable_user_notification4. Update from gform_disable_admin_notification5. Disable based on payment/subscription eventPlacementSource Code

Description

Use this filter to disable admin and user notification emails.

Usage

add_filter( 'gform_disable_notification', 'your_function_name', 10, 4 );

You can also specify this per form by adding the form id after the hook name.

add_filter( 'gform_disable_notification_6', 'your_function_name', 10, 4 );

Parameters

$is_disabled bool
Variable to be filtered. Set it to true to disable notifications

$notification array
Current Notification array

$form Form Object
Current form.

$entry Entry Object
Current Entry array

$data array
Array of data which can be used in the notifications via the generic {object:property} merge tag. Defaults to empty array. Since: 2.3.6.6.

Examples

1. Disable ALL Notifications

This example disables admin and user notifications for all forms

add_filter( 'gform_disable_notification', 'disable_notification', 10, 4 );
function disable_notification( $is_disabled, $notification, $form, $entry ) {
return true;
}

2. Disable a notification based on a field

This example shows you how to disable a notification conditionally based on a field of the entry. This can help you in situations where conditional logic can』t be used (e.g. To send a notification only if an upload field was not used).

add_filter( 'gform_disable_notification', 'disable_notification_by_field', 10, 4 );
function disable_notification_by_field( $is_disabled, $notification, $form, $entry ) {

$field_to_check = rgar( $entry, '1' ); // Replace 1 by your field id number

// Replace User Notification by your notification name.
if ( $notification['name'] == 'User Notification' && ! empty( $field_to_check ) ) { // Disable notification only if $filed_to_check is not empty.
return true;
}

return $is_disabled;
}

3. Update from gform_disable_user_notification

This example shows you how to update your code from the deprecated gform_disable_user_notification hook

add_filter( 'gform_disable_notification', 'disable_notification', 10, 4 );
function disable_notification( $is_disabled, $notification, $form, $entry ) {

//There is no concept of user notifications anymore, so we will need to disable notifications based on other criteria such as name
if ( $notification['name'] == 'User Notification' ) {
return true;
}

return $is_disabled;
}

4. Update from gform_disable_admin_notification

This example shows you how to update your code from the deprecated gform_disable_admin_notification hook

add_filter( 'gform_disable_notification', 'disable_notification', 10, 4 );
function disable_notification( $is_disabled, $notification, $form, $entry ) {

//There is no concept of admin notifications anymore, so we will need to disable notifications based on other criteria such as name
if ( $notification['name'] == 'Admin Notification' ) {
return true;
}

return $is_disabled;
}

5. Disable based on payment/subscription event

This example shows how a notification assigned to a payment or subscription event could be disabled based on the event properties.

add_filter( 'gform_disable_notification', function( $is_disabled, $notification, $form, $entry, $data ) {
if ( isset( $data['payment_action'] ) && empty( $data['payment_action']['amount'] ) ) {
$is_disabled = true;
}

return $is_disabled;
}, 10, 5 );

Placement

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

Source Code

This filter is located in GFAPI::send_notifications() in includes/api.php

gform_disable_installation_status

gform_disable_installation_status

DescriptionUsageParametersPlacementSource CodeSince

Description
This filter is used to disable the display of the Installation Status section on the Forms > Settings page.
Usage
1add_filter( 'gform_disable_installation_status', '__return_true' );
Parameters
This hook has no parameters.
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in GFSettings::gravityforms_settings_page() in settings.php
Since
This filter was added in Gravity Forms 1.9.11.1

gform_disable_form_theme_css

gform_disable_form_theme_css

DescriptionUsageParametersExamples1. Disable the themePlacementSinceSource Code

Description
The gform_disable_form_theme_css filter allows the default theme used by forms created with Gravity Forms 2.5 and greater to be disabled.
Usage
The filter which would run for all forms would be used like so:
add_filter( 'gform_disable_form_theme_css', 'your_function_name' );

Parameters

$disabled bool
Whether to disable the theme css.

Examples
1. Disable the theme
add_filter( 'gform_disable_form_theme_css', '__return_true' );

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 GFFormDisplay::get_form_enqueue_assets() in form_display.php.

gform_disable_form_legacy_css

gform_disable_form_legacy_css

DescriptionUsageParametersExamples1. Disable the CSSPlacementSinceSource Code

Description
The gform_disable_form_legacy_css filter allows the CSS to be disabled for forms using the legacy markup, usually forms created with Gravity Forms 2.4 and earlier.
Usage
The filter which would run for all forms using the legacy markup would be used like so:
add_filter( 'gform_disable_form_legacy_css', 'your_function_name' );

Parameters

$disabled bool
Whether to disable the CSS.

Examples
1. Disable the CSS
add_filter( 'gform_disable_form_legacy_css', '__return_true' );

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 GFFormDisplay::get_form_enqueue_assets() in form_display.php.

gform_disable_custom_field_names_query

gform_disable_custom_field_names_query

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
Allows the postmeta query which retrieves the custom field names (meta keys) to be disabled to help improve editor performance on some sites.
Usage
add_filter( 'gform_disable_custom_field_names_query', 'your_function_name', 10, 1 );

Parameters

$disable_query boolean
Indicates if the custom field names query should be disabled. Default is false.

Example
add_filter( 'gform_disable_custom_field_names_query', 'disable_query', 10, 1 );
function disable_query( $disable_query ){
return true;
}

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.4.1.
Source Code
This filter is located in GFFormsModel::get_custom_field_names() in forms_model.php.