gform_print_styles

gform_print_styles

DescriptionUsageParametersExamplesExample 1Example 2PlacementSource Code

Description
Use this filter to add custom stylesheets to the print entry screen.
Usage
add_filter( 'gform_print_styles', 'your_function_name', 10, 2 );

Parameters

$value booleanDefaults to false.
$form Form Object
Current form.

Examples
Example 1
This example adds the custom stylesheet print_entry.css to the print entry page when the form id is 1.
add_filter( 'gform_print_styles', 'add_styles', 10, 2 );
function add_styles( $value, $form ) {

if ( $form['id'] != 1 ) {
return $value;
}

wp_register_style( 'print_entry', get_template_directory_uri() . '/print_entry.css' );

return array( 'print_entry' );
}

Example 2
This example adds the custom stylesheet print_entry.css to the print entry page when the form id is 1 or 6.
add_filter( 'gform_print_styles', 'add_styles', 10, 2 );
function add_styles( $value, $form ) {
$forms = array( '1', '6' );

if ( ! in_array( $form['id'], $forms ) ) {
return $value;
}

wp_register_style( 'print_entry', get_template_directory_uri() . '/print_entry.css' );

return array( 'print_entry' );
}

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

gform_print_scripts

gform_print_scripts

DescriptionUsageParametersExamples1. Print custom scriptPlacementSinceSource Code

Description
The gform_print_scripts action hook is executed just after the scripts are printed to the page for the form widget or when a form embed is processed in a custom location using GFCommon::gform_do_shortcode().
Usage
1add_action( 'gform_print_scripts', 'your_function_name', 10, 2 );
You can also specify this per form by adding the form id after the hook name.
1add_action( 'gform_print_scripts_6', 'your_function_name', 10, 2 );

Parameters

$form Form Object
The current form object.

$is_ajax bool
Indicates if the form is configured to be submitted via AJAX.

Examples
1. Print custom script
This example prints a custom script for all AJAX enabled forms.
1234567add_action( 'gform_print_scripts', 'print_custom_script', 10, 2 );function print_custom_script( $form, $is_ajax ) {    if ( $is_ajax ) {        wp_enqueue_script( 'custom_script', 'path/file.js' );        wp_print_scripts( 'custom_script' );    }}
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::print_form_scripts() in form_display.php.

gform_print_entry_notes

gform_print_entry_notes

DescriptionUsageParametersExamplesAlways include the notesAlways exclude the notesInvert the choice selected in the adminPlacementSinceSource Code

Description
The gform_print_entry_notes filter allows printing of entry notes to be overridden as the entry markup is being prepared for the print view.
Usage
The following would apply to all forms:
add_filter( 'gform_print_entry_notes', 'your_function_name', 10, 3 );

Parameters

$print_entry_notes bool
Indicates if printing of notes was enabled via the entry list or detail pages.

$entry Entry Object
The current entry.

$form Form Object
The current form object.

Examples
Always include the notes
add_filter( 'gform_print_entry_notes', '__return_true' );
Always exclude the notes
add_filter( 'gform_print_entry_notes', '__return_false' );
Invert the choice selected in the admin
add_filter( 'gform_print_entry_notes', function ( $print_entry_notes ) {
return ! $print_entry_notes;
} );

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.4.17.
Source Code
This filter is located in gform_default_entry_content() in print-entry.php.

gform_print_entry_header

gform_print_entry_header

DescriptionUsageParametersExamplesSource Code

Description
This action hook can be used to add a custom header to the print entry screen.
Usage
add_action( 'gform_print_entry_header', 'custom_header', 10, 2 );

Parameters

$form Form Object
The current form.

$entry Entry Object
The current entry object.

Examples
This example adds a custom header to the Print Entry screen.
add_action( 'gform_print_entry_header', 'custom_header', 10, 2 );
function custom_header( $form, $entry ) {
echo "

Date and Time: " . $entry['date_created'] . "

";
}

Source Code
This filter is located in print-entry.php.

gform_print_entry_footer

gform_print_entry_footer

DescriptionUsageParametersExamplesSource Code

Description
This action hook can be used to add a custom footer to the print entry screen.
Usage
add_action( 'gform_print_entry_footer', 'custom_footer', 10, 2 );

Parameters

$form Form Object
The current form.

$entry Entry Object
The current entry array.

Examples
This example adds a custom footer to the Print Entry screen.
add_action( 'gform_print_entry_footer', 'custom_footer', 10, 2 );
function custom_footer( $form, $entry ) {
echo "


My custom footer";
}

Source Code
This filter is located in print-entry.php.

gform_print_entry_disable_auto_print

gform_print_entry_disable_auto_print

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
Disable auto-print when the Print Entry view has fully loaded.
Usage
The following would apply to all forms.
1add_filter( 'gform_print_entry_disable_auto_print', 'your_function_name', 10, 2 );
To target a specific form, append the form id to the hook name. (format: gform_print_entry_disable_auto_print_FORMID)
1add_filter( 'gform_print_entry_disable_auto_print_1', 'your_function_name', 10, 2 );

Parameters

false boolAuto print is enabled by default. Set to true to disable.
$form Form Object
Current form object.

Example
1add_filter( 'gform_print_entry_disable_auto_print', '__return_true', 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme.
Since
This filter was added in Gravity Forms version 1.9.14.16.
Source Code
This filter is located in print-entry.php.

gform_print_entry_content

gform_print_entry_content

DescriptionUsageParametersExamplesExample 1Example 2PlacementSinceSource Code

Description

Runs when entries are being displayed and allows a custom display to be used for the entry.

Usage

1add_action( 'gform_print_entry_content', 'my_function', 10, 3 );

Parameters

$form Form ObjectThe current form.
$entry Entry Object
The current entry.

$entry_ids array
The IDs of the entries being displayed.

Examples

Example 1

12345678910111213141516171819202122232425add_action( 'gform_print_entry_content', 'gform_default_entry_content', 10, 3 );function gform_default_entry_content( $form, $entry, $entry_ids ) {  $page_break = rgget( 'page_break' ) ? 'print-page-break' : false;  // Separate each entry inside a form element so radio buttons don't get treated as a single group across multiple entries.echo '

';  GFEntryDetail::lead_detail_grid( $form, $entry );  echo '

';  if ( rgget( 'notes' ) ) {$notes = GFFormsModel::get_lead_notes( $entry['id'] );if ( ! empty( $notes ) ) {GFEntryDetail::notes_grid( $notes, false );}}  // Output entry divider/page break.if ( array_search( $entry['id'], $entry_ids ) < count( $entry_ids ) - 1 ) {echo '

';}  }

Example 2

12345678910// Prevent the default content being output.add_action( 'gform_print_entry_content', function() {remove_action( 'gform_print_entry_content', 'gform_default_entry_content', 10 );}, 1 ); // Bind our custom entry content function.add_action( 'gform_print_entry_content', 'my_print_entry_content', 10, 3 );function my_print_entry_content( $form, $entry, $entry_ids ) {GFEntryDetail::lead_detail_grid( $form, $entry );}

Placement

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

Since

The filter was added in Gravity Forms version 1.9.14.16.

Source Code

This action hook is located in print-entry.php.

gform_price_change

gform_price_change

DescriptionUsageParametersExamplePlacementSinceSource Code

Description
JavaScript action hook that triggers when any pricing field is modified.
Usage

Parameters

event Event Object
Default JS event object.

productIds object
The form id and the id of the product field.

htmlInput string
The HTML input field.

Example
This example uses the gform_pre_render filter to load the hook.
add_action( 'gform_pre_render', 'do_price_stuff' );
function do_price_stuff( $form ) {
?>

gform_previous_button

gform_previous_button

DescriptionUsageParametersExamplesSource Code

Description
Allows the markup for the previous button to be changed.
Usage
Apply to all forms.
1add_filter( 'gform_previous_button', 'my_previous_button_markup', 10, 2 );
Apply to a specific form.
1add_filter( 'gform_previous_button_10', 'my_previous_button_markup', 10, 2 );
Parameters

$previous_button string
The default markup for the previous button.

$form Form Object
The current form.

Examples
This example demonstrates how to use to this hook to wrap the previous button in an extra

with a custom class. Useful when applying advanced CSS styling to the Previous (or Next) buttons.
1234567add_filter( 'gform_previous_button', 'my_previous_button_markup', 10, 2 );function my_previous_button_markup( $previous_button, $form ) {     $previous_button = '

' . $previous_button . '

';     return $previous_button;}
Source Code
This filter is located in GFFormDisplay::get_field() form_display.php

gform_preview_styles

gform_preview_styles

DescriptionUsageParametersExamplesSource Code

Description
Use this filter to specify styles to be enqueued on Gravity Forms preview pages.
Usage
add_filter( 'gform_preview_styles', 'your_function_name', 10, 2 );

Parameters

$styles array
Array of style handles to be enqueued.

$form Form Object
Current form.

Examples
This example enqueues a custom style on the preview page:
add_filter( 'gform_preview_styles', 'enqueue_custom_style', 10, 2) ;
function enqueue_custom_style( $styles, $form ) {
wp_register_style( 'my_style', get_stylesheet_directory_uri() . '/my_style.css' );
$styles = array( 'my_style' );
return $styles;
}

Source Code
This filter is located in preview.php.