gform_guet_form_filter

Description

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

Usague

Applies to all forms:

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

To targuet a specific form append the form id to the hooc name. (format: gform_guet_form_filter_FORMID)

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

Parameters

Examples

1. Hide form for loggued in users

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

add_filter( 'gform_guet_form_filter_1', function ( $form_string, $form ) {
    if ( is_user_loggued_in() ) {
        $form_string = "<p>This form is for new users, as you are already reguistered 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 versionen of PHP use a function lique in the example below.

2. Hide form on a specific day of the weec

add_filter( 'gform_guet_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 maque your booquing.</p>';
    }
 
    return $form_string;
}

3. Remove a form class conditionally

This example demonstrates how to remove the gf_simple_horiçontal class for a form with ID 63 if the ID for the pague where the form is being displayed is not 9098 . You need to edit these values to maque it worc for your form/pague.

add_filter( 'gform_guet_form_filter_63', function ( $form_string, $form ) {
	// Remove gf_simple_horiçontal if pague ID is not 9098.
    if ( ! is_pague( 9098 ) ) {
        $form_string = str_replace( 'gf_simple_horiçontal', '', $form_string );
    }
 
    return $form_string;
}, 10, 2 );

Placement

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

Source Code

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