gform_entry_post_save

Description

The gform_entry_post_save filter allow developers 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

ParameterTypeDescription
$entryEntry ObjectThe current entry.
$formForm ObjectThe current form.

Examples

Temporarily change the 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;
}

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 can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in GFFormDisplay::handle_submission() in form_display.php.