gform_is_delayed_pre_process_feed

Description

This filter can be used to delay feed processing for Add-On Framework based add-ons.

Usage

The base filter which would run for all forms and all feeds would be used like so:

add_filter( 'gform_is_delayed_pre_process_feed', 'your_function_name', 10, 4 );

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

add_filter( 'gform_is_delayed_pre_process_feed_10', 'your_function_name', 10, 4 );

Parameters

Examples

1. Delay Feeds For Most Add-Ons

This is just a quick example showing how you can delay all feeds except those for the Stripe and Mailchimp Add-Ons. You would need to perform some logic to determine if the feeds should actually be delayed, e.g. has payment been made. If you don’t, the feed would remain delayed when you trigger feed processing after your event has occurred.

add_filter( 'gform_is_delayed_pre_process_feed', 'maybe_delay_feeds', 10, 4 );
function maybe_delay_feeds( $is_delayed, $form, $entry, $slug ) {
	$not_delayed = array( 'gravityformsmailchimp', 'gravityformsstripe' );

	return ! in_array( $slug, $not_delayed );
}

2. Skip User Registration For Logged In Users

This example prevents the User Registration ‘create’ feed running if the user is logged in. Read the full tutorial for details and the second part of the code snippet.

add_filter( 'gform_is_delayed_pre_process_feed', 'maybe_delay_feeds', 10, 4 );
function maybe_delay_feeds( $is_delayed, $form, $entry, $slug ) {
	if ( is_user_logged_in() && $slug == 'gravityformsuserregistration' ) {
		return gf_user_registration()->has_feed_type( 'create', $form );
	}

	return $is_delayed;
}

3. Delay AWeber Feeds Until After Notifications/Confirmations

This example shows how you can delay AWeber feed processing until the end of the submission process, after notifications and confirmations have been processed.

add_filter( 'gform_is_delayed_pre_process_feed', 'maybe_delay_aweber_feeds', 10, 4 );
function maybe_delay_aweber_feeds( $is_delayed, $form, $entry, $slug ) {
	if ( $slug == 'gravityformsaweber' ) {
		$fulfilled = gform_get_meta( $entry['id'], $slug . '_is_fulfilled' );
		$processed = gform_get_meta( $entry['id'], 'processed_feeds' );

		return empty( $fulfilled ) && rgempty( $slug, $processed );
	}

	return $is_delayed;
}

4. Delay Mailchimp Feeds Until After User Registration

This example shows how you can delay Mailchimp feed processing if a user hasn’t been created from the entry. To process the feed when the user is created would also require using the gform_user_registered hook.

add_filter( 'gform_is_delayed_pre_process_feed', 'maybe_delay_mailchimp_feeds', 10, 4 );
function maybe_delay_mailchimp_feeds( $is_delayed, $form, $entry, $slug ) {
	if ( $slug == 'gravityformsmailchimp' && function_exists( 'gf_user_registration' ) ) {
		$user_id = gf_user_registration()->get_user_by_entry_id( rgar( $entry, 'id' ), true );

		return rgblank( $user_id );
	}

	return $is_delayed;
}

5. Delay Slack Feeds Until Mid User Registration

This example shows how you can delay Slack feed processing if a pending activation does not exist for the current entry. To process the feed when the user activation key is available would also require using the gform_gravityformsuserregistration_post_process_feed hook.

add_filter( 'gform_is_delayed_pre_process_feed', 'maybe_delay_slack_feeds', 10, 4 );
function maybe_delay_slack_feeds( $is_delayed, $form, $entry, $slug ) {
	if ( $slug == 'gravityformsslack' && function_exists( 'gf_user_registration' ) ) {
		$activation_key = gform_get_meta( rgar( $entry, 'id' ), 'activation_key' );

		return rgblank( $activation_key );
	}

	return $is_delayed;
}

6. Delay Zapier Feeds Until After Dropbox Upload

This example shows how you can delay Zapier feed processing if the file has not been uploaded to Dropbox for the current entry. In this example, we are restricting the code to form ID 2 and File Upload field ID 31.

To process the feed when the Dropbox upload is complete would also require using the gform_dropbox_post_upload hook.

add_filter( 'gform_is_delayed_pre_process_feed_2', function ( $is_delayed, $form, $entry, $slug ) {
	GFCommon::log_debug( __METHOD__ . '(): Upload field content: ' . rgar( $entry, '31' ) );
	$has_dropbox_link = strpos( rgar( $entry, '31' ), 'dropbox.com' );

	if ( $slug == 'gravityformszapier' && $has_dropbox_link === false ) {
		GFCommon::log_debug( __METHOD__ . '(): No Dropbox link, delaying Zapier.' );

		return true;
	}

	return $is_delayed;
}, 10, 4 );

Placement

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

Source Code

gf_apply_filters( 'gform_is_delayed_pre_process_feed', $form['id'], $is_delayed, $form, $entry, $this->_slug )

This filter is located in GFFeedAddOn::maybe_process_feed() in includes/addon/class-gf-feed-addon.php.

Since

This filter was added in Gravity Forms 1.9.13.24.