gform_disable_page_query_arg

Description

The gform_disable_page_query_arg filter allows developers to turn off the gf_page_{form_id} query argument on multi-page forms. When the filter returns true, the page number is not added to the URL, and links that include the argument open the form on the first page.

Note: Turning off the query argument also stops Validation Summary links from opening the page where the field appears.

Usage

The following would apply to all forms.

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

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_disable_page_query_arg_FORMID)

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

Parameters

ParameterTypeDescription
$disabledboolWhether the page query argument is disabled. Default false.
$formForm ObjectThe current form.

Examples

Turn off the page query argument for all forms.

add_filter( 'gform_disable_page_query_arg', '__return_true' );

Turn off the page query argument only when the Validation Summary is off.

Keeps the argument on forms that use the Validation Summary, so its links still open the page with the error.

add_filter( 'gform_disable_page_query_arg', 'disable_page_query_without_summary', 10, 2 );
function disable_page_query_without_summary( $disabled, $form ) {
    if ( rgar( $form, 'validationSummary' ) ) {
        return $disabled;
    }

    return true;
}

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?

Source Code

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

Since

This filter was added in Gravity Forms 3.2.1