gform_footer_init_scripts_filter

Description

Allows the scripts that fire in the footer to be modified.

Note: The gform_init_scripts_footer must be set to true so scripts are initialized in the footer of the site instead of the page body.

Usage

The following would apply to all forms:

add_filter( 'gform_footer_init_scripts_filter', 'your_function_name', 10, 3 );

To target a specific form, append the form id to the hook name. (format: gform_footer_init_scripts_filter_FORMID)

add_filter( 'gform_footer_init_scripts_filter_1', 'your_function_name', 10, 3 );

Parameters

  • $form_string string

    A string of the scripts used in the footer.

    <script type='text/javascript'> jQuery(document).bind('gform_post_render', function(event, formId, currentPage){if(formId == 75) {} } );jQuery(document).bind('gform_post_conditional_logic', function(event, formId, fields, isInit){} );</script><script type='text/javascript'> jQuery(document).ready(function(){jQuery(document).trigger('gform_post_render', [75, 1]) } ); </script>
        

  • $form Form Object

    The current form.

  • $current_page int

    The ID of the current page.

Example

add_filter( 'gform_footer_init_scripts_filter', 'filter_footer', 10, 3 );
function filter_footer( $form_string, $form, $current_page ){
	$form_string .= "<script type='text/javascript'>alert('Hello');</script>";
	return $form_string;
}

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.8.4.

Source Code

This filter is located in GFFormDisplay::footer_init_scripts() in form_display.php.