gform_is_asynchronous_notifications_enabled

Description

The gform_is_asynchronous_notifications_enabled filter can be used to enable or disable async (background) processing of notifications.

Async (background) processing of notifications is currently disabled by default while the feature is tested.

Enabling async processing of notifications can improve form submission performance, allowing the confirmation to be displayed faster.

Usage

The filter which runs for all forms would be used like so:

add_filter( 'gform_is_asynchronous_notifications_enabled', 'your_function_name', 10, 6 );

To limit the scope of your function to a specific form, append the form id to the end of the hook name. (format: gform_is_asynchronous_notifications_enabled_FORMID)

add_filter( 'gform_is_asynchronous_notifications_enabled_5', 'your_function_name', 10, 6 );

Parameters

  • $is_asynchronous boolean
    Indicates if async (background) processing of notifications enabled. Default is false.
  • $event string
    The event the notifications are to be sent for. Default is form_submission.
  • $notifications_to_send array
    An array containing the IDs of the notifications to be sent.
  • $form Form Object
    The form currently being processed.
  • $entry Entry Object
    The entry currently being processed.
  • $data array
    An array of data which can be used in the notifications via the generic {object:property} merge tag. Defaults to empty array.

Examples

Enable for ALL forms

This example shows how you can enable async (background) processing of notifications for all forms.

add_filter( 'gform_is_asynchronous_notifications_enabled', '__return_true' );

Disable for ALL forms

This example shows how you can disable async (background) processing of notifications for all forms.

add_filter( 'gform_is_asynchronous_notifications_enabled', '__return_false' );

Enable for a specific event

This example shows how you can enable async (background) processing of notifications for all forms, but only for those assigned to the Form is submitted event.

add_filter( 'gform_is_asynchronous_notifications_enabled', function ( $is_asynchronous, $event ) {
	return $event === 'form_submission';
}, 10, 2 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Gravity Forms v2.6.9.

Source Code

This filter is located in GFAPI::send_notifications() in /includes/api.php.