This filter allows you to override the form’s HTML after it has been generated but before it is displayed.


Applies to all forms:

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

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

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


  • $form_string string

    The form markup, including the init scripts (unless the gform_init_scripts_footer filter was used to move them to the footer).

  • $form

    The form currently being processed.


1. Hide form for logged in users

This example demonstrates how to hide the form if the user is logged in

add_filter( 'gform_get_form_filter_1', function ( $form_string, $form ) {
    if ( is_user_logged_in() ) {
        $form_string = "<p>This form is for new users, as you are already registered you don't need to use it again.</p>";

    return $form_string;
}, 10, 2 );

Anonymous functions (closures) as shown in the example above are only compatible with PHP 5.3 and newer. If you are using an older version of PHP use a function like in the example below.

2. Hide form on a specific day of the week

add_filter( 'gform_get_form_filter_1', 'custom_schedule', 10, 2 );
function custom_schedule( $form_string, $form ) {
    $day = date( 'l' );
    if ( $day == 'Monday' ) {
        $form_string = '<p>We are closed today, please return tomorrow to make your booking.</p>';

    return $form_string;


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

Source Code

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

Last modified: October 4, 2017