Using Gravity Forms ‘gform_partialentries_pre_update’ PHP filter

The gform_partialentries_pre_update filter is used to modify an existing partial entry before it is updated in the database.

Usage

The following example applies to all forms with the partial entries feature enabled when the partial entry is being updated by the Heartbeat API or when the user pages through a multi-page form.

add_filter('gform_partialentries_pre_update', 'your_function_name', 10, 3);

To target a specific form, add the form ID after the hook name:

add_filter('gform_partialentries_pre_update_6', 'your_function_name', 10, 3);

Parameters

  • $partial_entry (Entry Object) – The partial entry to be saved to the database. This will only contain the latest field values from the browser and a limited number of entry properties and meta. It won’t contain values set programmatically via other hooks and API methods.
  • $saved_entry (Entry Object) – The current version of the partial entry from the database.
  • $form (Form Object) – The form currently being processed.

More information

See Gravity Forms Docs: gform_partialentries_pre_update

Examples

Restore field value

The following example demonstrates how to restore a value from a field that was set programmatically but lost when the partial entry was updated. The value is copied from the current version of the partial entry in the database.

add_filter('gform_partialentries_pre_update', function($partial_entry, $saved_entry, $form) {
    $partial_entry['2'] = $saved_entry['2'];
    return $partial_entry;
}, 10, 3);

Place this code in the functions.php file of your active theme or a custom functions plugin.

This filter was added in version 1.6.1.

The filter is located in GF_Partial_Entries::filter_partial_entry_before_update() in class-gf-partial-entries.php.