Using Gravity Forms ‘gform_form_pre_process_async_task’ PHP action

The gform_form_pre_process_async_task Gravity Forms PHP function/filter/action allows you to modify the form object before notifications and add-on feeds are processed by the async (background) task processor.


A generic example of using the filter for all forms:

add_filter('gform_form_pre_process_async_task', 'your_function_name', 10, 2);

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

add_filter('gform_form_pre_process_async_task_5', 'your_function_name', 10, 2);


More information

See Gravity Forms Docs: gform_form_pre_process_async_task


Add choice based on entry value

This example demonstrates how to add a choice to a field object if the entry for another field contains a specific value.

add_filter('gform_form_pre_process_async_task', function($form, $entry) {
    if (rgar($entry, '1') === 'test') {
        $field = GFAPI::get_field($form, 2);
        if ($field && is_array($field->choices)) {
            $field->choices[] = array('text' => 'Testing', 'value' => 'test');
    return $form;
}, 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?

Since: This filter was added in Gravity Forms v2.6.9.

Source Code: This filter is located in GF_Background_Process::filter_form() in /includes/libraries/gf-background-process.php.