Action
uncanny-automator-pro
gform_post_update_entry
Fires after an entry has been successfully updated in Gravity Forms, providing access to the updated and original entry data.
add_action( 'gform_post_update_entry', $callback, 10, 2 );
Description
Fires after an entry has been successfully updated in Gravity Forms. Developers can use this hook to perform actions based on the updated entry data, such as triggering custom notifications or synchronizing data with external systems. The hook receives the updated entry object and the original entry object as parameters.
Usage
add_action( 'gform_post_update_entry', 'your_function_name', 10, 2 );
Parameters
-
$updated_entry(mixed) - This parameter contains the entry object that has just been updated in the database.
-
$entry(mixed) - This parameter contains the entry object that has just been updated.
Examples
/**
* Example function to hook into gform_post_update_entry.
* This function demonstrates how to access and potentially modify
* an entry after it has been updated in Gravity Forms.
*
* @param array $updated_entry The entry object after it has been updated.
* @param array $original_entry The entry object before the update.
*/
function my_gravity_forms_entry_updated( $updated_entry, $original_entry ) {
// Check if a specific field's value has changed.
// For example, let's say we want to do something if the 'Email' field (field ID 1) was updated.
if ( isset( $updated_entry['1'] ) && isset( $original_entry['1'] ) && $updated_entry['1'] !== $original_entry['1'] ) {
// Get the new and old email addresses.
$new_email = $updated_entry['1'];
$old_email = $original_entry['1'];
// Log the change or perform some other action.
// In a real-world scenario, you might send a notification,
// update another system, or trigger a workflow.
error_log( sprintf(
'Gravity Forms Entry ID %s: Email address updated from "%s" to "%s".',
$updated_entry['id'],
$old_email,
$new_email
) );
// Example: Update a custom field in the entry if a specific condition is met.
// Let's assume there's a custom field with ID 5 for internal notes.
// We'll append a note indicating the email change.
$custom_notes_field_id = 5;
$note_to_append = sprintf(
'Email updated on %s. Previous: %s, New: %s.',
date('Y-m-d H:i:s'),
$old_email,
$new_email
);
// Get current notes, if any, and append the new one.
$current_notes = isset( $updated_entry[ $custom_notes_field_id ] ) ? $updated_entry[ $custom_notes_field_id ] . "n" : '';
$updated_entry[ $custom_notes_field_id ] = $current_notes . $note_to_append;
// You would typically use GFAPI::update_entry() here to save the changes.
// However, be cautious as this hook fires *after* the entry has already been updated.
// Re-updating might have unintended consequences or performance issues if not managed carefully.
// For demonstration purposes, we'll just show how to construct the data.
// If you intended to modify the entry *before* it's saved, you'd use a different hook.
// Example of updating (use with caution):
// GFAPI::update_entry( $updated_entry );
}
// You can also access other information from the entry arrays.
// For example, get the form ID from the updated entry.
$form_id = $updated_entry['form_id'];
// Perform actions based on the form ID.
if ( $form_id == 10 ) { // Example: If the updated entry is from Form ID 10
// Do something specific for form 10
}
}
add_action( 'gform_post_update_entry', 'my_gravity_forms_entry_updated', 10, 2 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
uncanny-automator-pro/src/integrations/gravity-forms/actions/gf-update-entry.php:211
}
// Get the updated entry object
$updated_entry = GFAPI::get_entry( $entry_id );
// Trigger update hooks
do_action( 'gform_after_update_entry', $form, $entry_id, $entry );
do_action( 'gform_post_update_entry', $updated_entry, $entry );
return true;
}
/**
* Validate field values based on their field types.
*