Documentation

gform_pre_submission

  1. Description
  2. Usage
  3. Parameters
  4. Examples
  5. Placement
  6. Source Code

Description

This action hook is executed after form validation, but before any notifications are sent and the entry is stored. This action can be used to modify the posted values prior to creating the entry.

Usage

Applies to all forms

<?php
add_action( 'gform_pre_submission', 'pre_submission' );
?>

Applies to a specific form. In this case, form Id 5

<?php
add_action( 'gform_pre_submission_5', 'pre_submission' );
?>

Parameters

Examples

This example changes the post variable for field 14;

<?php
add_action( 'gform_pre_submission', 'pre_submission_handler' );
function pre_submission_handler( $form ) {
    $_POST['input_14'] = 'new value for field 14';
}
?>

This example changes the post variable for field 14 to the value of field 5;

<?php
add_action( 'gform_pre_submission', 'pre_submission_handler' );
function pre_submission_handler( $form ) {
    $_POST['input_14'] = rgpost( 'input_5' );
}
?>

Placement

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

Source Code

This action hook is located in form_display.php