Description
The gform_max_async_task_attempts
filter allows developers to set the number of retries to be modified before the task is abandoned.
Note: This filter does not apply to the background feed processor. For that, use gform_max_async_feed_attempts.
Usage
add_filter( 'gform_max_async_task_attempts', 'your_function_name', 10, 4 );
Parameters
Parameter | Type | Description |
---|---|---|
$max_attempts | int | The maximum number of attempts allowed. Default: 1 . |
$task | mixed | The task about to be processed. |
$batch | object | The batch currently being processed. |
$identifier | string | The string used to identify the type of background process. |
Examples
Increase Retry Limit for Async Notification Tasks
add_filter( 'gform_max_async_task_attempts', 'custom_max_async_task_attempts', 10, 4 );
function custom_max_async_task_attempts( $max_attempts, $task, $batch, $identifier ) {
if ( $identifier === 'wp_gf_notifications_processor' ) {
return 5;
}
return $max_attempts; // Leave other processes unchanged.
}
Source Code
The filter is located in \Gravity_Forms\Gravity_Forms\Async\GF_Background_Process::can_process_task()
in includes/async/class-gf-background-process.php
Since
Gravity Forms 2.9.9
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?