The gform_aweber_args_pre_subscribe Gravity Forms PHP filter allows you to modify the subscription parameters (arguments) before they are sent to AWeber.
Usage
To use the filter for all AWeber feeds:
add_filter('gform_aweber_args_pre_subscribe', 'your_function_name', 10, 4);
To limit the scope of the filter to a single form, append the form ID to the hook name:
add_filter('gform_aweber_args_pre_subscribe_5', 'your_function_name', 10, 4);
Parameters
$args
(array) – An associative array containing all the parameters to be passed to AWeber.$form
(Form Object) – The form currently being processed.$entry
(Entry Object) – The entry currently being processed.$feed
(Feed Object) – The feed currently being processed.
More information
See Gravity Forms Docs: gform_aweber_args_pre_subscribe
Examples
Add ip_address Parameter
The following example demonstrates how to add the ip_address parameter.
add_filter('gform_aweber_args_pre_subscribe', function($args, $form, $entry, $feed) { $args['ip_address'] = rgar($entry, 'ip'); return $args; }, 10, 4);
Place this code snippet in the functions.php
file of your active theme.
Add custom field to AWeber
The following example demonstrates how to add a custom field named “custom_field_name” to AWeber.
add_filter('gform_aweber_args_pre_subscribe', function($args, $form, $entry, $feed) { $args['custom_fields']['custom_field_name'] = 'custom_field_value'; return $args; }, 10, 4);
Modify email address before submission
The following example demonstrates how to modify the email address before it is sent to AWeber.
add_filter('gform_aweber_args_pre_subscribe', function($args, $form, $entry, $feed) { $args['email'] = 'modified_' . $args['email']; return $args; }, 10, 4);
Change name fields
The following example demonstrates how to change the first and last name fields before they are sent to AWeber.
add_filter('gform_aweber_args_pre_subscribe', function($args, $form, $entry, $feed) { $args['name'] = 'New First Name'; $args['last_name'] = 'New Last Name'; return $args; }, 10, 4);
Set a custom AWeber tag
The following example demonstrates how to set a custom AWeber tag for the subscriber.
add_filter('gform_aweber_args_pre_subscribe', function($args, $form, $entry, $feed) { $args['tags'] = array('custom_tag'); return $args; }, 10, 4);
Place all the code snippets in the functions.php
file of your active theme.