Using Gravity Forms ‘gform_addon_pre_process_feeds’ PHP filter

The gform_addon_pre_process_feeds filter allows you to modify the feed objects before they are processed during form submission in Gravity Forms.

Usage

To apply the filter, you can use the following code:

add_filter('gform_addon_pre_process_feeds', 'your_function_name', 10, 3);

Generic, Form-specific: applies to feeds for all add-ons for a specific form.

add_filter( 'gform_addon_pre_process_feeds_{FORM_ID}', 'your_function_name' );

Addon-specific: applies to feeds for a specific add-on for all forms.

add_filter( 'gform_{ADDON_SLUG}_pre_process_feeds', 'your_function_name', 10, 3 );

See the Gravity Forms Add-On Slugs article for a list of possible slugs.

Addon-specific, Form-specific: applies to feeds for a specific add-on and form.

add_filter( 'gform_{ADDON_SLUG}_pre_process_feeds_{FORM_ID}', 'your_function_name' );

Parameters

  • $feeds (array): An array of Feed Objects.
  • $entry (Entry Object): Current entry for which $feeds will be processed.
  • $form (Form Object): Current form object.

More information

See Gravity Forms Docs: gform_addon_pre_process_feeds

Examples

Convert User Registration “Create” Feeds to “Update” Feeds if User is Logged-in

This example converts user registration “Create” feeds to “Update” feeds if the user is logged in:

add_filter('gform_gravityformsuserregistration_pre_process_feeds', function($feeds) {
    if (is_user_logged_in() && is_array($feeds)) {
        foreach($feeds as &$feed) {
            $feed['meta']['feedType'] = 'update';
        }
    }
    return $feeds;
});

Override the User Registration Role Setting

This example overrides the choice selected for the User Registration feed of form 2 with the value of a form field during form submission:

add_filter('gform_gravityformsuserregistration_pre_process_feeds_2', function($feeds, $entry) {
    foreach($feeds as &$feed) {
        $feed['meta']['role'] = rgar($entry, '5');
    }
    return $feeds;
}, 10, 2);

Override Mailchimp Feed Setting

This example shows how you can override a setting on a Mailchimp feed:

add_filter('gform_gravityformsmailchimp_pre_process_feeds', function($feeds, $entry) {
    foreach($feeds as &$feed) {
        $feed['meta']['double_optin'] = false;
    }
    return $feeds;
}, 10, 2);

Place this code in the functions.php file of your active theme.