gform_update_PROPERTY_NAME

Description

Use this action hook to perform logic when entries’ basic information is updated.

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.

Examples

Delete spam entry

This example automatically deletes entries that are 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

This example sends an email to the admin whenever 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 );
	}
}

This example sends an email to the admin whenever 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

This example shows how you can process add-on 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' || ! class_exists( 'GFFeedAddOn' ) ) {
		return;
	}

	$entry = GFAPI::get_entry( $entry_id );
	if ( is_wp_error( $entry ) ) {
		return;
	}

	$form   = GFAPI::get_form( rgar( $entry, 'form_id' ) );
	$addons = GFAddOn::get_registered_addons( true );

	foreach ( $addons as $addon ) {
		if ( $addon instanceof GFPaymentAddOn || ! $addon instanceof GFFeedAddOn || $addon->get_slug() === 'gravityformsuserregistration' ) {
			continue;
		}

		$addon->log_debug( 'gform_update_status: triggering feed processing on "not spam" event.' );
		$addon->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.