gform_form_after_open

Description

This filter allows markup to be added directly after the opening form wrapper.

Usage

Applies to all forms:

add_filter( 'gform_form_after_open', 'your_function_name', 10, 2 );

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

add_filter( 'gform_form_after_open_10', 'your_function_name', 10, 2 );

Parameters

  • $markup string
    The current string to append.
  • $form Form Object
    The form currently being processed.

Examples

add_filter( 'gform_form_after_open', 'add_lead_in_before_title', 10, 2 );
function add_lead_in_before_title( $markup, $form ) {
	$lead_in_text = __( 'Contact Options', 'theme-slug' );
	$html         = sprintf( '<h4>%s,</h4>', $lead_in_text );

	return $markup . $html;
}

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity Forms v2.7

Source Code

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