The gform_is_feed_asynchronous Gravity Forms PHP filter can be used to enable or disable background processing of feeds. This feature prevents feed processing from impacting form submission performance.
Usage
add_filter( 'gform_is_feed_asynchronous', 'your_function_name', 10, 4 );
Parameters
- $is_asynchronous (bool) – Indicates if background (async) feed processing is enabled or disabled.
- $feed (array) – The Feed Object currently being processed.
- $form (array) – The Form Object currently being processed.
- $entry (array) – The Entry Object currently being processed.
More information
See Gravity Forms Docs: gform_is_feed_asynchronous
Examples
Turn off background processing for the specified feed name
This example uses the feed name to limit the scope of the snippet.
add_filter( 'gform_is_feed_asynchronous', function ( $is_asynchronous, $feed, $form, $entry ) { GFCommon::log_debug( __METHOD__ . '(): running.' ); $feed_name = rgars( $feed, 'meta/feedName' ); // Run only for this feed name. if ( $feed_name === 'Your feed name here' ) { GFCommon::log_debug( __METHOD__ . '(): Disabling background processing for feed: ' . $feed_name ); $is_asynchronous = false; } return $is_asynchronous; }, 10, 4 );
Enable background processing for specific add-ons
These examples check the add-on slug from the $feed to enable background processing for specific add-ons.
Single add-on
add_filter( 'gform_is_feed_asynchronous', function ( $is_asynchronous, $feed ) { $target_slug = 'the-slug-goes-here'; if ( rgar( $feed, 'addon_slug' ) === $target_slug ) { $is_asynchronous = true; } return $is_asynchronous; }, 10, 2 );
Multiple add-ons
add_filter( 'gform_is_feed_asynchronous', function ( $is_asynchronous, $feed ) { $target_slugs = array( 'slug1', 'slug2', ); if ( in_array( rgar( $feed, 'addon_slug' ), $target_slugs ) ) { $is_asynchronous = true; } return $is_asynchronous; }, 10, 2 );
Disable for User Registration Auto Login
This example shows how background feed processing can be disabled for the User Registration add-on when using older versions of the Auto Login perk.
add_filter( 'gform_is_feed_asynchronous', function ( $is_asynchronous, $feed ) { if ( ! $is_asynchronous || ! class_exists( 'GP_Auto_Login' ) || rgar( $feed, 'addon_slug' ) !== 'gravityformsuserregistration' ) { return $is_asynchronous; } return GP_Auto_Login::get_instance()->is_auto_login_enabled( $feed ) ? false : $is_asynchronous; }, 10, 2 );
If you’re enabling auto login via custom code, you can use the following approach instead.
add_filter( 'gform_is_feed_asynchronous', function ( $is_asynchronous, $feed ) { if ( ! $is_asynchronous || rgar( $feed, 'addon_slug' ) !== 'gravityformsuserregistration' ) { return $is_asynchronous; } return gf_user_registration()->is_update_feed( $feed ) ? $is_asynchronous : false; }, 10, 2 );
Placement
This code can be placed in the `functions.php` file of the active theme, a custom functions plugin, or a custom add-on.
See also the PHP section in this article: [Where Do I Put This Code?](https://docs.gravityforms.com/where-do-i-put-this-code/)
Source Code
This filter is located in `class-gf-feed-addon.php`.