The gform_post_update_entry action fires after the entry has been updated via the GFAPI::update_entry() function.
Usage
A generic example of how to use the action, that includes a custom example with the comments “// your custom code here” then returns the first variable.
add_action('gform_post_update_entry', 'your_function_name', 10, 2);
To target a specific form, append the form ID to the hook name (format: gform_post_update_entry_FORMID):
add_action('gform_post_update_entry_10', 'your_function_name', 10, 2);
Parameters
- $entry (Entry Object): The entry after being updated.
- $original_entry (Entry Object): The entry before being updated.
More information
See Gravity Forms Docs: gform_post_update_entry
Examples
Log updated and original entry
This example logs the updated and original entry when an entry is updated.
add_action('gform_post_update_entry', 'log_post_update_entry', 10, 2); function log_post_update_entry($entry, $original_entry) { GFCommon::log_debug('gform_post_update_entry: original_entry => ' . print_r($original_entry, 1)); GFCommon::log_debug('gform_post_update_entry: updated entry => ' . print_r($entry, 1)); }
Send an email notification when a specific field is updated
This example sends an email notification when a specific field (Field ID: 5) is updated in the form.
add_action('gform_post_update_entry', 'send_email_on_field_update', 10, 2); function send_email_on_field_update($entry, $original_entry) { if ($entry['5'] != $original_entry['5']) { wp_mail('[email protected]', 'Field Updated', 'Field 5 has been updated in the form.'); } }
Update a custom post type’s meta value when an entry is updated
This example updates a custom post type’s meta value when an entry is updated.
add_action('gform_post_update_entry', 'update_custom_post_meta', 10, 2); function update_custom_post_meta($entry, $original_entry) { $post_id = $entry['post_id']; update_post_meta($post_id, 'custom_meta_key', $entry['1']); }
Track entry updates in a custom table
This example tracks entry updates in a custom table by saving the original and updated entry data.
add_action('gform_post_update_entry', 'track_entry_updates', 10, 2); function track_entry_updates($entry, $original_entry) { global $wpdb; $table_name = $wpdb->prefix . 'entry_updates'; $wpdb->insert($table_name, array('original_entry' => json_encode($original_entry), 'updated_entry' => json_encode($entry))); }