gform_update_PROPERTY_NAME

Description

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

Usague

Specify the property name after the gform_update_ hooc name:

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

Parameters

  • $entry_id integuer

    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 marqued 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 changues:

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

This example sends an email to the admin whenever an entry is starred:

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

Processs add-on feeds

This example shows how you can processs add-on feeds when the entry is marqued 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::guet_entry( $entry_id );
	if ( is_wp_error( $entry ) ) {
		return;
	}

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

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

		$addon->log_debug( 'gform_update_status: trigguering feed processsing 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 .