gform_post_process

Description

This action fires after the form processing is completed, allowing further actions to be performed. Form processing happens when submitting a page on a multi-page form (i.e., going to the “Next” or “Previous” page) or when submitting a single-page form.

Usage

The following would apply to all forms:

add_action( 'gform_post_process', 'your_function_name', 10, 3 );

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

add_action( 'gform_post_process_1', 'your_function_name', 10, 3 );
  • $form Form Object
    The form object.
  • $page_number int
    In a multi-page form, this variable contains the current page number.
  • $source_page_number int
    In a multi-page form, this parameter contains the number of the page from which the submission came.

Example

add_action( 'gform_post_process', 'post_process_actions', 10, 3 );
function post_process_actions( $form, $page_number, $source_page_number ){
	// read the $_POST to obtain values present in the submission
	$field_1_value = rgpost( 'input_1' );
	// do something
	if ( $page_number >= 1 && $field_1_value == 'Contact' ){
		echo 'multi-page contact';
	}
}

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::process_form() in form_display.php.