Description
Use this filter to perform actions right after an entry has been saved. This fires 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.
Examples
1. Temporarily change field value
This example appends the text “testing” to the value of field 1 in the lead. 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; }
2. 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; } );
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
apply_filters( 'gform_entry_post_save', $lead, $form )
This filter is located in GFFormDisplay::handle_submission() in form_display.php.