Using Gravity Forms ‘gform_entry_id_pre_save_lead’ PHP filter

The gform_entry_id_pre_save_lead filter allows you to change the entry ID before the submission is saved, which can be useful for updating an existing entry instead of creating a new one.

Usage

Apply to all forms:

add_filter('gform_entry_id_pre_save_lead', 'my_update_entry_on_form_submission', 10, 2);

Apply to a specific form:

add_filter('gform_entry_id_pre_save_lead_10', 'my_update_entry_on_form_submission', 10, 2);

Parameters

  • $entry_id (integer): Default value is null.
  • $form (Form Object): The current form.

More information

See Gravity Forms Docs: gform_entry_id_pre_save_lead

Examples

Update an existing entry

This example demonstrates how to use this filter to retrieve an entry ID from the $_POST data and return it, so the existing entry is updated rather than a new entry created.

Assume that the entry ID to be updated has been submitted with the form from an input with the input name “my_update_entry_id”. You can store it in any input, but you need to update the input name used when you retrieve the value via the rgpost() function.

add_filter('gform_entry_id_pre_save_lead', 'my_update_entry_on_form_submission', 10, 2);

function my_update_entry_on_form_submission($entry_id, $form) {
    $update_entry_id = rgpost('my_update_entry_id');
    return $update_entry_id ? $update_entry_id : $entry_id;
}

Note: This example assumes that you have a form input with the name “my_update_entry_id” containing the entry ID to be updated.