Use this filter to enable or disable the confirmation anchor functionality that will automatically scroll the page to the confirmation text or validation message upon submission, it also takes effect when browsing between pages of a multi-page form. You can also force the page to scroll to a specified distance (pixel) from the top of the page. Useful when embedding forms in a long page.

When the anchor is present the page scrolls to the top of the form. When the anchor is not present for non-ajax forms then when the page reloads it will remain at the top of the page. For AJAX forms when the anchor is not present then the page will not move when the form content is updated. It’s possible, depending on the page layout, that the padding and margin changes associated with displaying validation errors that eye will think the page has scrolled when in fact it hasn’t.


The base filter which would run for all forms would be used like so:

add_filter( 'gform_confirmation_anchor', 'your_function_name' );

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

add_filter( 'gform_confirmation_anchor_5', 'your_function_name' );


  • $anchor bool

    Parameter to be filtered. Following are the possible values that can be set to this variable to control how the anchor will behave. Default: True (anchor present) when AJAX enabled or for multi-page non-AJAX forms. False (no anchor) for single page non-AJAX forms.

    • Set $anchor to true -> Page will scroll to the position where the form is located.
    • Set $anchor to false -> Page will not scroll. For AJAX forms, the page scroll position won’t change when the form is submitted. For non-AJAX forms, the page will remain at the top of document after being reloaded.
    • Set $anchor to any numeric value -> Page will be scrolled to the specified pixel value from the top of the document.
  • $form

    The current form. Available from Gravity Forms


Enable for all forms

The following example enables the confirmation anchor on all forms

add_filter( 'gform_confirmation_anchor', '__return_true' );

Disable for a specific form

The following example disables the confirmation anchor for form with ID 5

add_filter( 'gform_confirmation_anchor_5', '__return_false' );

Set scroll distance

The following example causes all AJAX enabled forms to scroll to 20 pixels from the top of the document after being submitted.

add_filter( 'gform_confirmation_anchor', function() {
    return 20;
} );


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

Source Code

This filter is located in the following methods in form_display.php:

  • GFFormDisplay::get_form()
  • GFFormDisplay::handle_confirmation()
  • GFFormDisplay::replace_save_variables()
  • GFFormDisplay::handle_save_email_confirmation()
  • GFFormDisplay::handle_save_confirmation()

Last modified: October 4, 2017