gform_form_not_found_message

gform_form_not_found_message

DescriptionUsageParametersExamplePlacementSource Code

Description
The 「gform_form_not_found_message」 filter in Gravity Forms allows the default form message, 「Oops! We could not locate your form.」 to be changed.
Usage
add_filter( 'gform_form_not_found_message', 'your_function_name', 10, 2 );

Parameters

$message string
The default form not found message.

$id int
The ID of the form attempted to be used.

Example
add_filter( 'gform_form_not_found_message', 'change_message', 10, 2 );
function change_message( $message, $id ){
return "We could not find the form with id " . $id;
}

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

gform_form_list_forms

gform_form_list_forms

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
The 「gform_form_list_forms」 filter in Gravity Forms allows the forms displayed on the form listing page to be filtered. It should be used in conjunction with the gform_form_list_count hook to adjust the counts.
Usage
add_filter( 'gform_form_list_forms', 'your_function_name', 10, 6 );

Parameters

$forms array
The complete list of forms.

$search_query string
The search query string if set.

$active bool
If inactive forms should be displayed.

$sort_column string
List column being sorted.

sort_direction string
Direction of column sorting.

trash bool
If trash items should be displayed.

Examples
add_filter( 'gform_form_list_forms', 'filter_forms', 10, 6 );
function filter_forms( $forms, $search_query, $active, $sort_column, $sort_direction, $trash ){
//remove half of the forms
$forms = array_slice( $forms,0, round( count($forms)/2 ) );
return $forms;
}

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 GF_Form_List_Table::prepare_items() in form_list.php.

gform_form_list_count

gform_form_list_count

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
The 「gform_form_list_count」 filter in Gravity Forms allows the form list count array to be modified. This is useful when filtering the form count list. This filter should be used with the gform_form_list_forms hook.
Usage
1add_filter( 'gform_form_list_count', 'your_function_name', 10, 1 );

Parameters

$form_count array
The form count by filter name.

Examples
This example simply sets the active form count to 20.
12345add_filter( 'gform_form_list_count', 'change_list_count', 10, 1 );function change_list_count( $form_count ){  $form_count['active'] = 20;  return $form_count;}
This example reduces the form count by half and reflects the change in active or inactive. Trash is not counted in the total.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748add_filter( 'gform_form_list_count', 'change_list_count', 10, 1 );function change_list_count( $form_count ){    if ( ! isset( $_GET['filter'] ) ){        $filter = '';    }    else{        $filter = $_GET['filter'];    }     switch ( $filter ) {            case 'active' :                //remove half of forms that are active, adjust total                $orig_count = $form_count['active'];                $form_count['active'] =  round( $form_count['active']/2 );                $form_count['total'] = $form_count['total'] - ( $orig_count - $form_count['active'] );                break;            case 'inactive' :                //remove half of forms that are inactive, adjust total                $orig_count = $form_count['inactive'];                $form_count['inactive'] =  round( $form_count['inactive']/2 );                $form_count['total'] = $form_count['total'] - ( $orig_count - $form_count['inactive'] );                break;            case 'trash' :                //remove half of forms that are trash, do NOT adjust total because trash is not counted in total                $form_count['trash'] = round( $form_count['trash']/2 );                break;            default :                //all forms, remove half and adjust counts                $orig_count = $form_count['total'];                $active_count = $form_count['active'];                $inactive_count = $form_count['inactive'];                $form_count['total'] = round( $form_count['total']/2 );                $number_to_remove = $orig_count - $form_count['total'];                //active and inactive counts need to be modified since the form array will be removing active/inactive items                //remove active forms first, if there are less active forms than the new form total, need to remove from inactive as well                if ( $active_count < $number_to_remove ){                    //remove active                    $form_count['active'] = 0;                    //remove inactive                    $form_count['inactive'] = $inactive_count - ($number_to_remove - $active_count);                }                else{                    //just remove active                    $form_count['active'] = $active_count - $number_to_remove;                }    }    return $form_count;} 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 GF_Form_List_Table::get_views() in form_list.php.

gform_form_list_columns

gform_form_list_columns

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
Allows the column headers displayed on the Form List page to be modified.
Usage
add_filter( 'gform_form_list_columns', 'your_function_name', 10, 1 );

Parameters

$columns
An array of the columns to display.
//default values
array(
'cb' => '',
'is_active' => '',
'title' => esc_html__( 'Title', 'gravityforms' ),
'id' => esc_html__( 'ID', 'gravityforms' ),
'entry_count' => esc_html__( 'Entries', 'gravityforms' ),
'view_count' => esc_html__( 'Views', 'gravityforms' ),
'conversion' => esc_html__( 'Conversion', 'gravityforms' ),
);

Examples
This example renames Title to Form Title, removes the column for the checkbox to apply actions, removes entry count, removes view count, and removes the conversion.
add_filter( 'gform_form_list_columns', 'change_columns', 10, 1 );
function change_columns( $columns ){
$columns = array(
'is_active' => '',
'id' => esc_html__( 'ID', 'gravityforms' ),
'title' => esc_html__( 'Form Title', 'gravityforms' ),
);
return $columns;
}

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.0.
Source Code
This filter is located in GF_Form_List_Table::get_columns() in form_list.php.

gform_form_export_filename

gform_form_export_filename

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
Allows the form export filename to be changed.
Note: Do not include a file extension. The extension 「.json」 is added.
Usage
add_filter( 'gform_form_export_filename', 'your_function_name', 10, 1 );

Parameters

$filename string
The new filename to use for the export file.

Example
add_filter( 'gform_form_export_filename', function( $filename ) {
return 'new-filename-without-extension';
} );

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.
Source Code
This filter is located in GFExport::export_forms() in export.php.

gform_form_editor_can_field_be_added

gform_form_editor_can_field_be_added

DescriptionUsageParametersExampleSource Code

Description
This filter fires on the Form Editor page when a field button is clicked or dragged on to the form, it can be used to prevent a field being added to the form if the conditions you define are not met.
Usage
1234gform.addFilter('gform_form_editor_can_field_be_added', function (canFieldBeAdded, type) {    // return false to prevent a field being added.    return canFieldBeAdded;});

Parameters

canFieldBeAdded boolean
Defaults to true.

type string
The current field type.

Example
This example uses the gform_admin_pre_render filter to load the hook on the form editor page.
1234567891011121314151617181920add_filter( 'gform_admin_pre_render', function ( $form ) {    echo GFCommon::is_form_editor() ? "        " : '';     //return the form object from the php hook    return $form;} );
Source Code
This filter is located in js.php

gform_form_args

gform_form_args

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description
The filter gform_form_args provides the ability to modify the options used to display the form.
Usage
1add_filter( 'gform_form_args', 'your_function_name', 10, 1 );

Parameters

$form_args array
An array of Form Arguments when adding it to a page/post (like the ID, Title, AJAX or not, etc.). Possible values in array:

form_id – the form id or title
display_title – true/false
display_description – true/false
force_display – true/false
field_values – An array of dynamic population parameter keys with their corresponding values to be populated.
ajax – true/false
tabindex – number

Examples
1234567add_filter( 'gform_form_args', 'setup_form_args' );function setup_form_args( $form_args ) {    $form_args['display_title'] = false;    $form_args['display_description'] = true;     return $form_args;}
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms 1.9.
Source Code
This filter is located in GFFormDisplay::get_form() in form_display.php.

gform_form_actions

gform_form_actions

DescriptionUsageParametersExamplesAdd custom action linkRemove Duplicate action linkSource Code

Description
Use this filter to add custom form actions which display below the form title in the Form List view.
Usage
add_filter( 'gform_form_actions', 'form_actions', 10, 2 );

Parameters

$actions array
An associative array containing all of the default form actions (ie Edit, Preview, Notifications, etc.).
array(
'edit' => 'Edit',
'preview' => 'Preview',
'entries' => 'Entries',
'notifications' => 'Notifications',
'duplicate' => 'Duplicate',
'delete' => 'Delete'
);

$form_id integer
The ID of the field from which the entry value was submitted.

Examples
Add custom action link
This example demonstrates how to add an custom form action.
add_action( 'gform_form_actions', 'add_mergedoc_link', 10, 4 );
function add_mergedoc_link( $actions, $form_id ) {
$actions['mergedoc_settings'] = "" . __( 'MergeDoc', 'gravityformsmergedoc' ) . "";
return $actions;
}

Remove Duplicate action link
This example demonstrates how to remove the default Duplicate action link.
add_action( 'gform_form_actions', 'remove_duplicate_link', 10, 4 );
function remove_duplicate_link( $actions, $form_id ) {
// Remove Duplicate action link
unset ( $actions['duplicate'] );
return $actions;
}

Source Code
This filter is located in GFFormList::form_list_page() in form_list.php

gform_force_hooks_js_output

gform_force_hooks_js_output

DescriptionUsageParametersExamplesPlacementSinceSource Code

Description

The gform_force_hooks_js_output filter can be used to prevent the Gravity Forms scripts from being injected into the pages if they』re not necessary.

Usage

1add_filter( 'gform_force_hooks_js_output', 'your_function_name' );

Parameters

Defaults to true. Set to false using __return_false or a custom function to set to false.

Examples

1add_filter( 'gform_force_hooks_js_output', '__return_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.5.3.1.

Source Code

This filter is located in Gravity_FormsGravity_FormsLibrariesDom_Parser::get_injected_html() in includes/libraries/class-dom-parser.php and GFForms::localize_hook_vars() in gravityforms.php.