Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j0ssGZ/9617f9d28f9c91c17551a3f046c2b562 to your computer and use it in GitHub Desktop.
Save j0ssGZ/9617f9d28f9c91c17551a3f046c2b562 to your computer and use it in GitHub Desktop.
How to do MailChimp MERGE field with ADDRESS type
<?php
//Address merge types must be handled in a very specific format
function my_pmpro_mailchimp_listsubscribe_fields($fields, $user)
{
$user_info = get_userdata($user->ID);
$new_fields = array(
"FNAME" => $user->first_name,
"EMAIL" => $user->email,
"LNAME" => $user->last_name,
"ADDRESS" => array( 'addr1' => $user_info->pmpro_baddress1,
'addr2' => $user_info->pmpro_baddress2,
'city' => $user_info->pmpro_bcity,
'state' => $user_info->pmpro_bstate,
'zip' => $user_info->pmpro_bzipcode,
'country' => $user_info->pmpro_bcountry)
);
$fields = array_merge($fields, $new_fields);
return $fields;
}
add_action('pmpro_mailchimp_listsubscribe_fields', 'my_pmpro_mailchimp_listsubscribe_fields', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment