Description
The gform_entry_created action fires after the lead has been created, but before the post has been created, notifications have been sent, and the confirmation has been processed.
Usage
add_action( 'gform_entry_created', 'your_function_name', 10, 2 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$entry | Entry Object | The entry that was just created. |
$form | Form Object | The current form. |
Examples
Add a value to the entry meta.
This example demonstrates how to use to the gform_entry_created hook to populate a value in the entry’s entry meta. It is possible to populate the entry meta anywhere you have the entry ID; however, let’s assume that we’re going to retrieve this entry meta and replace a gform_custom_merge_tags.
add_action( 'gform_entry_created', 'generate_mergedoc' );
function generate_mergedoc( $entry, $form ) {
$feed = self::get_mergedoc_feeds( $form['id'] );
if ( empty( $feed ) || ! rgar( $feed, 'active' ) || ! $entry )
return;
// get download link
$download_link = self::get_download_link( $uid );
// update entry meta
gform_update_meta( $entry['id'], 'gfmergedoc_download_link', $download_link );
}
Delete an entry property
The following example shows how you can delete an entry property such as the user agent from the database.
add_action( 'gform_entry_created', function( $entry ) {
GFAPI::update_entry_property( $entry['id'], 'user_agent', '' );
} );
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.