# Detect which field changed after admin update \[RESOLVED\]

**URL:** <https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297>\
**Category:** Get Help\
**Tags:** gform\_after\_update\_entry, send\_notifications\
**Created:** [January 24, 2023, 9:16pm UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297 "2023-01-24T21:16:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![user628d39d893d0b169](https://avatars.discourse-cdn.com/v4/letter/u/58956e/32.png) [@user628d39d893d0b169](https://community.gravityforms.com/u/user628d39d893d0b169)\
**Post date:** [January 24, 2023, 9:16pm UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297/1 "2023-01-24T21:16:37Z")

</div>

Is there a way to know which field changed when an admin makes an update to an entry?

---

<div class="post-metadata">

**Author:** ![faisalahammad](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/faisalahammad/32/13948_2.png) [@faisalahammad](https://community.gravityforms.com/u/faisalahammad)\
**Post date:** [January 25, 2023, 9:58am UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297/2 "2023-01-25T09:58:07Z")

</div>

It is possible to track which fields were updated in a Gravity Forms entry by utilizing the [gform\_after\_update\_entry](https://docs.gravityforms.com/gform_after_update_entry/) hook, which is triggered after an entry is updated. Within the callback function for this hook, you can access the original and updated entry data, and compare the two to determine which fields have been altered.

Alternatively, you can also track changes by using the [GravityRevisions](https://www.gravitykit.com/extensions/entry-revisions/) or [Entry Revisions](https://gravityextend.com/gravityforms_plugin/entry-revisions/) Add-on. This allows you to keep a record of the modifications made to an entry and revert back to previous versions if necessary.

---

<div class="post-metadata">

**Author:** ![user628d39d893d0b169](https://avatars.discourse-cdn.com/v4/letter/u/58956e/32.png) [@user628d39d893d0b169](https://community.gravityforms.com/u/user628d39d893d0b169)\
**Post date:** [January 25, 2023, 7:03pm UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297/3 "2023-01-25T19:03:15Z")

</div>

Thanks so much Faisal – this works beautifully.

I would also like to trigger an email notification. How would I accomplish that within the gform\_after\_update\_entry hook?

---

<div class="post-metadata">

**Author:** ![faisalahammad](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/faisalahammad/32/13948_2.png) [@faisalahammad](https://community.gravityforms.com/u/faisalahammad)\
**Post date:** [January 25, 2023, 7:50pm UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297/4 "2023-01-25T19:50:31Z")

</div>

You can use the `wp_mail()` function to send an email notification within the callback function for the `gform_after_update_entry` hook.

Here is an example of how you can send an email notification when a specific field is updated:

```auto
add_action( 'gform_after_update_entry', 'send_update_notification', 10, 2 );

function send_update_notification( $form, $entry_id ) {
  
  // Get the original entry
  $original_entry = GFAPI::get_entry( $entry_id );
  // Get the updated entry
  $updated_entry = GFFormsModel::get_current_lead();
  
  // Compare the two entries to determine which fields have been updated
  $updated_fields = array();
  foreach ( $updated_entry as $key => $value ) {
    if ( $original_entry[$key] !== $value ) {
      $updated_fields[] = $key;
    }
  }
  
  // Check if the specific field has been updated
  if ( in_array( 'your_field_id', $updated_fields ) ) {
    // Send email notification
    wp_mail( 'your@email.com', 'Gravity Form Entry Updated', 'An entry has been updated in your Gravity Form.' );
  }
}

```

In this example, we use the GFAPI::get\_entry() function to retrieve the original entry and GFFormsModel::get\_current\_lead() function to obtain the updated entry. We then compare the two entries to determine which fields have been modified and verify if a specific field has been altered.

You can customize the subject and body of the email and employ various mailer plugins such as Mailgun or SendGrid to send email notifications.

Ensuring that your server is correctly configured to send emails and that your hosting provider permits sending emails from your domain are essential.

---

<div class="post-metadata">

**Author:** ![user628d39d893d0b169](https://avatars.discourse-cdn.com/v4/letter/u/58956e/32.png) [@user628d39d893d0b169](https://community.gravityforms.com/u/user628d39d893d0b169)\
**Post date:** [January 25, 2023, 8:10pm UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297/5 "2023-01-25T20:10:47Z")

</div>

Thanks so much for the example, Faisal. I have been using the “gform\_after\_update\_entry” hook, but this is another way which is always good to learn.

Is there any way to trigger an email that is already configured as a GForms notification? Currently, users are using the “Resend” option inside the edit screen, but I’d like to automate it.

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [January 26, 2023, 5:25pm UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297/6 "2023-01-26T17:25:47Z")

</div>

Hi Margaret. To trigger an existing notification (rather than using wp\_mail to send a message) please use `GFAPI::send_notifications`:

> **[Sending Notifications with the GFAPI](https://docs.gravityforms.com/sending-notifications-with-the-gfapi/)**
>
> The GFAPI::send\_notifications() method is used to send notifications for a specific event and the given form and entry.

Basically, this line:

```auto
wp_mail( 'your@email.com', 'Gravity Form Entry Updated', 'An entry has been updated in your Gravity Form.' );

```

Will be replaced by something like this:

```auto
GFAPI::send_notifications( $form, $entry, 'my_update_event' );

```

`my_update_event` will be a custom notification event you create:

> **[gform\_notification\_events](https://docs.gravityforms.com/gform_notification_events/)**
>
> Use this filter to add a new event to the drop down of available triggers for notifications.

---

<div class="post-metadata">

**Author:** ![user628d39d893d0b169](https://avatars.discourse-cdn.com/v4/letter/u/58956e/32.png) [@user628d39d893d0b169](https://community.gravityforms.com/u/user628d39d893d0b169)\
**Post date:** [January 26, 2023, 8:41pm UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297/7 "2023-01-26T20:41:18Z")

</div>

This is perfect, Chris, works exactly how I need it to. Thanks so much!

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [January 29, 2023, 7:11pm UTC](https://community.gravityforms.com/t/detect-which-field-changed-after-admin-update-resolved/14297/8 "2023-01-29T19:11:42Z")

</div>

Closed on January 29, 2023, 7:11pm UTC


