Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of using the pmpro_mailchimp_listsubscribe_fields filter to send extra fields to MailChimp.
/*
Sync fields to MailChimp
*/
function my_pmpro_mailchimp_listsubscribe_fields($fields, $user)
{
$new_fields = array(
"TITLE" => $user->title,
"COMPANY" => $user->company,
"ADDRESS" => $user->address,
"CITY" => $user->city,
"STATE" => $user->state,
"ZIPCODE" => $user->zipcode,
"COUNTY" => $user->county,
"REGION" => $user->region,
"INDUSTRY" => $user->industry,
"PHONE" => $user->phone);
$fields = array_merge($fields, $new_fields);
return $fields;
}
add_action('pmpro_mailchimp_listsubscribe_fields', 'my_pmpro_mailchimp_listsubscribe_fields', 10, 2);
/*
(Optional) Tell PMPro MailChimp to always synchronize user profile updates. By default it only synchronizes if the user's email has changed.
Requires PMPro Mailchimp v2.0.3 or higher.
*/
add_filter('pmpromc_profile_update', '__return_true');
@meowwtoo

This comment has been minimized.

Copy link

@meowwtoo meowwtoo commented Jun 17, 2015

Hi, do I put this in the functions.php of my theme (child theme)? I did but it doesn't work.

@kimcoleman

This comment has been minimized.

Copy link

@kimcoleman kimcoleman commented Jan 4, 2021

An update to this recipe can be found here: https://gist.github.com/kimcoleman/44b1447804fc120f0eeba3935d4cb1bf. Please also note that if the fields you are sending are new merge fields, they must first be created in Mailchimp.

You can do this manually through the Mailchimp dashboard or use the pmpro_mailchimp_merge_fields filter to create them through the API like the example recipe here: https://gist.github.com/dparker1005/13ab3295d92818b3e46c53b0ca0268ba

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment