gform_post_paging

Description

Use this hook to perform actions after going to the next or previous page on a multi-page form.

Usage

add_action( 'gform_post_paging', 'set_default_value', 10, 3 );

You can also specify this per form by adding the form id after the hook name.

add_action( 'gform_post_paging_1', 'set_default_value', 10, 3 );

Parameters

  • $form Form Object

    Current form.

  • $source_page_number integer

    Number of page user is coming from.

  • $current_page_number integer

    Current page number.

Example

This example shows how you can use javascript to display a message to the screen when on page two.

add_action( 'gform_post_paging', 'alert_user', 10, 3 );
function alert_user( $form, $source_page_number, $current_page_number ) {
    if ( $current_page_number == 2 ) {
        echo '<script>alert( \'Almost done! Just one more page to fill out.\' );</script>';
    }
}

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 action hook is located in GFFormDisplay::get_form() in form_display.php.