Using Gravity Forms ‘gform_entry_pre_handle_confirmation’ PHP action

The gform_entry_pre_handle_confirmation Gravity Forms PHP filter allows you to modify the entry data before the confirmation is processed.

Usage

add_filter('gform_entry_pre_handle_confirmation', 'your_function_name', 10, 2);

Parameters

  • $entry (Entry Object): The current entry.
  • $form (Form Object): The current form.

More information

See Gravity Forms Docs: gform_entry_pre_handle_confirmation

Examples

Change Email Address Based on Name

This example modifies the email address field if the name field contains “Rocketgenius”.

add_filter('gform_entry_pre_handle_confirmation', 'change_entry', 10, 2);
function change_entry($entry, $form) {
    if (rgar($entry, '1.3') == 'Rocketgenius' || rgar($entry, '1.6') == 'Rocketgenius') {
        $entry['2'] = '[email protected]';
    }
    return $entry;
}

Add a Note to the Entry

This example adds a note to the entry based on a specific condition.

add_filter('gform_entry_pre_handle_confirmation', 'add_note', 10, 2);
function add_note($entry, $form) {
    if (rgar($entry, '5') > 1000) {
        $entry['8'] = 'Large order received.';
    }
    return $entry;
}

Modify Total Amount

This example applies a 10% discount if the order total is greater than $500.

add_filter('gform_entry_pre_handle_confirmation', 'apply_discount', 10, 2);
function apply_discount($entry, $form) {
    if (rgar($entry, '7') > 500) {
        $entry['7'] = $entry['7'] * 0.9;
    }
    return $entry;
}

Change Confirmation URL Based on a Field Value

This example changes the confirmation URL based on the user’s selected package.

add_filter('gform_entry_pre_handle_confirmation', 'change_confirmation_url', 10, 2);
function change_confirmation_url($entry, $form) {
    if (rgar($entry, '3') == 'Premium') {
        $entry['confirmation_url'] = 'https://example.com/premium-package';
    }
    return $entry;
}

Update a Custom Field in the Entry

This example updates a custom field with the user’s full name.

add_filter('gform_entry_pre_handle_confirmation', 'update_full_name', 10, 2);
function update_full_name($entry, $form) {
    $entry['custom_full_name'] = rgar($entry, '1.3') . ' ' . rgar($entry, '1.6');
    return $entry;
}