bookmark_bordergform_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

  • $is_delayed boolean

    Is feed processing delayed?

  • $form

    The Form currently being processed.

  • $entry Entry Object

    The Entry currently being processed.

  • $slug string

    The Add-On slug, including the gravityforms prefix. See the Gravity Forms Add-On Slugs article for a list of possible slugs.

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( $entry['id'], true );

		return rgblank( $user_id );
	}

	return $is_delayed;
}

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.