gform_review_page

Description

This filter is executed before the form is displayed and can be used to insert a review page before the final form submission.

Usage

The following would apply to all forms.

add_filter( 'gform_review_page', 'your_function_name' );

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

add_filter( 'gform_review_page_6', 'your_function_name' );

Parameters

  • $review_page array
    The review page to be created:
	array(
		'content'        => '',
		'cssClass'       => '',
		'is_enabled'     => false,
		'nextButton'     => array(
			'type'     => 'text',
			'text'     => __( 'Review Form', 'gravityforms' ),
			'imageUrl' => '',
			'imageAlt' => '',
		),
		'previousButton' => array(
			'type'     => 'text',
			'text'     => __( 'Previous', 'gravityforms' ),
			'imageUrl' => '',
			'imageAlt' => '',
		),
	);

Examples

Example 1

This example enables the review page and populates it with the {all_fields} merge tag.

add_filter( 'gform_review_page', 'add_review_page', 10, 3 );
function add_review_page( $review_page, $form, $entry ) {

    // Enable the review page
    $review_page['is_enabled'] = true;

    if ( $entry ) {
        // Populate the review page.
        $review_page['content'] = GFCommon::replace_variables( '{all_fields}', $form, $entry );
    }

    return $review_page;
}

Example 2

This example changes the text of the “Review Form” button.

// NOTE: Update the '221' to the ID of your form.
add_filter( 'gform_review_page_221', 'change_review_page_button', 10, 3 );
function change_review_page_button( $review_page, $form, $entry ) {

    $review_page['nextButton']['text'] = 'Review & Submit';

    return $review_page;
}

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

gf_apply_filters( 'gform_review_page', $form['id'], $review_page, $form, $partial_entry );

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