Description
The gform_partialentries_pre_update filter is used to modify an existing partial entry before the database is updated.
Usage
The following would run for 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 );
You can also target a specific form by adding 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.
Examples
Restore field value
The following example shows how a value from a field set programmatically, which is lost when the partial entry is updated, can be restored by copying it from the current version of the partial entry from 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 );
Placement
This code should be placed in the functions.php file of your active theme or a custom functions plugin.
Since
This filter was added in version 1.6.1.
Source Code
This filter is located in GF_Partial_Entries::filter_partial_entry_before_update() in class-gf-partial-entries.php.