Gform confirmation anchor

Description

Use this filter to enable or disable the confirmation anchor functionality that will automatically scroll the page to the confirmation text upon submission. 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.

Usage

Enables the confirmation anchor on all forms

<?php
add_filter("gform_confirmation_anchor", create_function("","return true;"));
?>


Enables the confirmation anchor on a specific form. In this case, form Id 5

<?php
add_filter("gform_confirmation_anchor_5", create_function("","return true;"));
?>

Parameters

$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.
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 its scroll position (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.

Examples

The following example enables the confirmation anchor on all forms

<?php
add_filter("gform_confirmation_anchor", create_function("","return true;"));
?>


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

<?php
add_filter("gform_confirmation_anchor", create_function("","return 20;"));
?>

Placement

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

Source Code

This filter is located in form_display.php

Search the Documentation