CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 20:09:07 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
vary: Accept-Encoding
strict-transport-security: max-age=604800
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-frame-options: SAMEORIGIN
referrer-policy: no-referrer
referrer-policy: strict-origin-when-cross-origin
link: ; rel="https://api.w.org/"
link: ; rel="alternate"; title="JSON"; type="application/json"
link: ; rel=shortlink
fastcgi-cache: MISS
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=dkuMKCMzTWryWO4VuftPjcR7mf7ilY%2Fp7fDyFZvkbhftBdmX1nB5iJoDuwNU%2BK6vfxg2ectRh9qOwnzZ7SH6E68%2FtSHoIqYebxTZ9F%2FXK5ZlIpd2"}]}
cf-cache-status: DYNAMIC
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
content-encoding: gzip
cf-ray: 98d0fe445858c181-BLR
gform_pre_print_scripts - Gravity Forms Documentation
gform_pre_print_scripts
Description
The gform_pre_print_scripts action hook is executed just before 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
add_action( 'gform_pre_print_scripts', 'your_function_name', 10, 2 );
You can also specify this per form by adding the form id after the hook name.
add_action( 'gform_pre_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.
add_action( 'gform_pre_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.