The gform_max_async_feed_attempts filter allows you to modify the number of retries before a feed is abandoned in Gravity Forms.
Usage
add_filter('gform_max_async_feed_attempts', 'your_filter_name', 10, 5);
Parameters
- $max_attempts (int): The maximum number of retries allowed. The default is 1.
- $form (Form Object): The form object.
- $entry (Entry Object): The entry object.
- $addon_slug (string): The add-on slug.
- $feed (Feed Object): The feed object.
More information
See Gravity Forms Docs: gform_max_async_feed_attempts
Examples
Change maximum attempts for a specific add-on
This example increases the maximum attempts to 2 for the ‘gravityformswebhooks’ add-on.
add_filter('gform_max_async_feed_attempts', 'filter_gform_max_async_feed_attempts', 10, 5); function filter_gform_max_async_feed_attempts($max_attempts, $form, $entry, $addon_slug, $feed) { if ($addon_slug == 'gravityformswebhooks') { $max_attempts = 2; } return $max_attempts; }
Increase maximum attempts for all add-ons
This example sets the maximum attempts to 3 for all add-ons.
add_filter('gform_max_async_feed_attempts', 'increase_max_async_feed_attempts', 10, 5); function increase_max_async_feed_attempts($max_attempts, $form, $entry, $addon_slug, $feed) { $max_attempts = 3; return $max_attempts; }
Decrease maximum attempts based on form ID
This example decreases the maximum attempts to 1 only for the form with ID 5.
add_filter('gform_max_async_feed_attempts', 'decrease_max_attempts_for_form', 10, 5); function decrease_max_attempts_for_form($max_attempts, $form, $entry, $addon_slug, $feed) { if ($form['id'] == 5) { $max_attempts = 1; } return $max_attempts; }
Modify maximum attempts based on entry value
This example increases the maximum attempts to 4 if the entry value for field 3 is ‘high’.
add_filter('gform_max_async_feed_attempts', 'change_max_attempts_based_on_entry_value', 10, 5); function change_max_attempts_based_on_entry_value($max_attempts, $form, $entry, $addon_slug, $feed) { if ($entry[3] == 'high') { $max_attempts = 4; } return $max_attempts; }
Set maximum attempts to unlimited
This example sets the maximum attempts to unlimited (not recommended, as it may cause performance issues).
add_filter('gform_max_async_feed_attempts', 'set_unlimited_max_attempts', 10, 5); function set_unlimited_max_attempts($max_attempts, $form, $entry, $addon_slug, $feed) { $max_attempts = -1; return $max_attempts; }