Action
uncanny-automator-pro
gform_after_submission
Fires after a Gravity Form entry has been successfully submitted.
add_action( 'gform_after_submission', $callback, 10, 2 );
Description
Fires after a Gravity Forms entry has been successfully created and saved to the database. Developers can use this hook to perform custom actions, such as triggering third-party integrations, sending notifications, or manipulating the entry data before it's finalized. The $entry and $form objects are passed for convenient access to submission details.
Usage
add_action( 'gform_after_submission', 'your_function_name', 10, 2 );
Parameters
-
$entry(mixed) - The `$entry` parameter is a Gravity Forms Entry object containing all submitted data.
-
$form(mixed) - This parameter contains the entry object for the Gravity Forms submission.
Examples
<?php
/**
* Example of how to use the gform_after_submission WordPress action hook.
* This function will log the entry ID and form title to the WordPress debug log
* after a Gravity Form has been successfully submitted.
*/
add_action( 'gform_after_submission', 'my_custom_gform_after_submission_logger', 10, 2 );
/**
* Logs Gravity Form submission details to the WordPress debug log.
*
* @param array $entry The entry object.
* @param array $form The form object.
*/
function my_custom_gform_after_submission_logger( $entry, $form ) {
// Ensure we have valid entry and form data.
if ( ! is_array( $entry ) || ! is_array( $form ) ) {
return;
}
// Log the entry ID and form title.
// Requires WP_DEBUG and WP_DEBUG_LOG to be enabled in wp-config.php.
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
error_log( sprintf(
'Gravity Forms Submission: Entry ID %s submitted for Form "%s" (Form ID: %d).',
$entry['id'],
$form['title'],
$form['id']
) );
}
}
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-createentry.php:159
public function process_action( $user_id, $action_data, $recipe_id, $args, $parsed ) {
$form_id = Automator()->parse->text( $action_data['meta'][ $this->action_meta ], $recipe_id, $user_id, $args );
$fields = json_decode( $action_data['meta']['GF_FIELDS'] ?? '[]' );
$gfrom_input_values = $this->gf->helpers->format_input_values( $fields, $recipe_id, $user_id, $args );
// Format time fields if present
$gfrom_input_values = $this->time_handler->format_time_fields( $gfrom_input_values, $form_id );
$gfrom_input_values['form_id'] = absint( $form_id );
$gfrom_input_values['created_by'] = $user_id;
$entry_id = GFAPI::add_entry( $gfrom_input_values );
if ( is_wp_error( $entry_id ) ) {
$error_message = $entry_id->get_error_message();
throw new Exception( esc_html( $error_message ) );
}
// Get the entry and form objects
$entry = GFAPI::get_entry( $entry_id );
$form = GFAPI::get_form( $entry['form_id'] );
// Manually trigger the form submission action
do_action( 'gform_after_submission', $entry, $form );
// Trigger other actions if necessary (e.g., for third-party integrations)
do_action( 'gform_entry_created', $entry, $form );
do_action( 'gform_post_add_entry', $entry, $form );
$this->hydrate_tokens(
array(
'ENTRY_ID' => $entry_id,
'ENTRY_URL' => $this->gf->helpers->get_entry_url( $entry_id, $form_id ),
)
);
return true;
}