gform_after_update_entry

Description

This hook fires after the entry has been updated via the entry detail page.

Usage

The following would run for any form:

add_action( 'gform_after_update_entry', 'your_function_name', 10, 2 );

To target a specific form append the form id to the hook name. (format: gform_after_update_entry_FORMID)

add_action( 'gform_after_update_entry_10', 'your_function_name', 10, 2 );

Parameters

  • $form Form Object
    The form object for the entry.
  • $entry_id integer
    The entry ID.
  • $original_entry Entry Object
    The entry before being updated. Since 1.9.12.9.

Examples

1. Update entry properties.

This example sets the entry as unread and stars it.

add_action( 'gform_after_update_entry', 'update_entry', 10, 2 );
function update_entry( $form, $entry_id ) {
  GFAPI::update_entry_property( $entry_id, 'is_read', 0 );
  GFAPI::update_entry_property( $entry_id, 'is_starred', 1 );
}

2. Log the entry before and after update.

add_action( 'gform_after_update_entry', 'log_post_update_entry', 10, 3 );
function log_post_update_entry( $form, $entry_id, $original_entry ) {
  $entry = GFAPI::get_entry( $entry_id );
  GFCommon::log_debug( 'gform_after_update_entry: original_entry => ' . print_r( $original_entry, 1 ) );
  GFCommon::log_debug( 'gform_after_update_entry: updated entry => ' . print_r( $entry, 1 ) );
}

3. Trigger Zapier Feed

This example shows how you can send the updated entry to Zapier.

add_action( 'gform_after_update_entry', 'send_to_zapier_on_update', 10, 2 );
function send_to_zapier_on_update( $form, $entry_id ) {
    $entry = GFAPI::get_entry( $entry_id );
    if ( class_exists( 'GFZapier' ) ) {
        GFZapier::send_form_data_to_zapier( $entry, $form );
    } elseif ( function_exists( 'gf_zapier' ) ) {
        gf_zapier()->maybe_process_feed( $entry, $form );
        gf_feed_processor()->save()->dispatch();
    }
}

4. Trigger Mailchimp Feed

This example shows how you can send the updated entry to Mailchimp.

add_action( 'gform_after_update_entry', 'send_to_mailchimp_on_update', 10, 2 );
function send_to_mailchimp_on_update( $form, $entry_id ) {
    if ( function_exists( 'gf_mailchimp' ) ) {
        $entry = GFAPI::get_entry( $entry_id );
        gf_mailchimp()->maybe_process_feed( $entry, $form );
        gf_feed_processor()->save()->dispatch();
    }
}

You can use this same snippet for other similar add-ons like Zoho CRM, AgileCRM, ActiveCampaign, etc… Replacing gf_mailchimp above by the corresponding add-on function name, like gf_zohocrm, gf_agilecrm, gf_activecampaign, etc…

5. Trigger Webhooks Feed

This example shows how you can trigger processing of Webhooks feeds which use the background (async) processing feature.

add_action( 'gform_after_update_entry', function ( $form, $entry_id ) {
    if ( function_exists( 'gf_webhooks' ) ) {
        $entry = GFAPI::get_entry( $entry_id );
        gf_webhooks()->maybe_process_feed( $entry, $form );
        gf_feed_processor()->save()->dispatch();
    }
}, 10, 2 );

6. Add note

This example shows how you can add a note to the entry.

add_action( 'gform_after_update_entry', function ( $form, $entry_id ) {
    $current_user = wp_get_current_user();
    GFAPI::add_note( $entry_id, $current_user->ID, $current_user->display_name, 'the note to be added' );
}, 10, 2 );

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 GFEntryDetail::lead_detail_page() in entry_detail.php.