Using Gravity Forms ‘gform_update_PROPERTY_NAME’ PHP action

The gform_update_PROPERTY_NAME action hook performs logic when the basic information of an entry is updated in Gravity Forms.

Usage

Specify the property name after the gform_update_ hook name:

add_action('gform_update_status', 'status_changed', 10, 3);

Parameters

  • $entry_id (integer) – Current entry ID.
  • $property_value (mixed) – New value of the entry’s property.
  • $previous_value (mixed) – Previous value of the entry’s property.

More information

See Gravity Forms Docs: gform_update_PROPERTY_NAME

Examples

Delete spam entry

Automatically delete entries marked as Spam:

add_filter('gform_update_status', 'delete_spam', 10, 3);
function delete_spam($entry_id, $property_value, $previous_value) {
  if ($property_value == 'spam') {
    GFAPI::delete_entry($entry_id);
  }
}

Send email when entry status changes

Send an email to the admin when an entry’s status changes:

add_action('gform_update_status', 'check_lead_status', 10, 3);
function check_lead_status($entry_id, $property_value, $previous_value) {
  if ($previous_value != $property_value) {
    $to = get_bloginfo('admin_email');
    $subject = "The status of entry {$entry_id} has changed.";
    $message = "The status of entry {$entry_id} has changed. Please review this entry.";
    wp_mail($to, $subject, $message);
  }
}

Send email when entry is starred

Send an email to the admin when an entry is starred:

add_action('gform_update_is_starred', 'check_starred_status', 10, 3);
function check_starred_status($entry_id, $property_value, $previous_value) {
  if ($previous_value != $property_value && $property_value == 1) {
    $to = get_bloginfo("admin_email");
    $subject = "Entry {$entry_id} has been starred as important.";
    $message = "Entry {$entry_id} has been starred as important. Please review this entry.";
    wp_mail($to, $subject, $message);
  }
}

Process add-on feeds when entry marked as not spam

Process Advanced Post Creation feeds when the entry is marked as not spam:

add_action('gform_update_status', function ($entry_id, $property_value, $previous_value) {
  if ($previous_value !== 'spam' || $property_value !== 'active' || !function_exists('gf_advancedpostcreation')) {
    return;
  }
  $entry = GFAPI::get_entry($entry_id);
  if (is_wp_error($entry)) {
    return;
  }
  $form = GFAPI::get_form(rgar($entry, 'form_id'));
  gf_advancedpostcreation()->maybe_process_feed($entry, $form);
  gf_feed_processor()->save()->dispatch();
}, 10, 3);

Placement
This code should be placed in the functions.php file of your active theme.

Source Code
This filter is located in GFFormsModel::update_lead_property() in forms_model.php.