Using Gravity Forms ‘gform_entry_post_save’ PHP filter

The gform_entry_post_save filter in Gravity Forms is used to perform actions immediately after an entry has been saved. This filter is triggered before notifications are sent and before the confirmation is processed.

Usage

add_filter('gform_entry_post_save', 'post_save', 10, 2);

Parameters

  • $entry (Entry Object) – The current entry.
  • $form (Form Object) – The current form.

More information

See Gravity Forms Docs: gform_entry_post_save

Examples

Temporarily change field value

This example appends the text “testing” to the value of field 1 in the entry. This new value will be available for use in notifications and confirmations, but the updated text is NOT saved with the entry.

add_filter('gform_entry_post_save', 'post_save', 10, 2);
function post_save($entry, $form) {
    $entry['1'] = rgar($entry, '1') . ' testing';
    return $entry;
}

Change Entry Property

This example shows how you can change an entry property such as the ‘source_url’ and save the change.

add_filter('gform_entry_post_save', function ($entry) {
    $entry['source_url'] = 'the new url here';
    GFAPI::update_entry_property($entry['id'], 'source_url', $entry['source_url']);
    return $entry;
});

Custom function after entry saved

This example shows how to perform a custom action after an entry has been saved.

add_filter('gform_entry_post_save', 'post_save_action', 10, 2);
function post_save_action($entry, $form) {
    // your custom code here
    return $entry;
}

Update a field value after entry saved

This example shows how to update a field value after an entry has been saved.

add_filter('gform_entry_post_save', 'update_field_value', 10, 2);
function update_field_value($entry, $form) {
    $entry['2'] = 'Updated field value';
    return $entry;
}

Send a custom email after entry saved

This example shows how to send a custom email after an entry has been saved.

add_filter('gform_entry_post_save', 'send_custom_email', 10, 2);
function send_custom_email($entry, $form) {
    $to = '[email protected]';
    $subject = 'New Form Entry';
    $message = 'A new entry has been submitted.';
    wp_mail($to, $subject, $message);
    return $entry;
}

Note: The code should be placed in the functions.php file of your active theme.