Description
Modify all possible feeds before they are processed by Gravity Forms.
Usage
Generic: applies to feeds for all add-ons and all forms.
1 | 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.
1 | 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.
1 | 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.
1 | 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.
Examples
1. Convert User Registration “Create” Feeds to “Update” Feeds if User is Logged-in
1 2 3 4 5 6 7 8 9 10 | 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 ; } ); |
2. Override the User Registration Role Setting
This example shows how the choice selected for the User Registration feed of form 2 can be overridden with the value of a form field during form submission. The form field choices would need to be configured with the roles.
1 2 3 4 5 6 7 8 | add_filter( 'gform_gravityformsuserregistration_pre_process_feeds_2' , function ( $feeds , $entry ) { foreach ( $feeds as & $feed ) { // use the value submitted for field 5 as the role $feed [ 'meta' ][ 'role' ] = rgar( $entry , '5' ); } return $feeds ; }, 10, 2 ); |
3. Override Mailchimp Feed Setting
This example shows how you can override a setting on a Mailchimp feed. See the Mailchimp Feed Meta article for the available settings.
1 2 3 4 5 6 7 | add_filter( 'gform_gravityformsmailchimp_pre_process_feeds' , function ( $feeds , $entry ) { foreach ( $feeds as & $feed ) { $feed [ 'meta' ][ 'double_optin' ] = false; } return $feeds ; }, 10, 2 ); |
Placement
This code should be placed in the functions.php file of your active theme.
Source Code
This filter is located in /includes/addon/class-gf-feed-addon.php.
Since
This filter was added in Gravity Forms 2.0-beta-2.