I spent quite a few hours getting my custom profile fields into MailChimp.
My custom fields were
Gender [s2member unique id was gender]
Age [s2member unique id was age]
Country [s2member unique id was country_code]
S2Member->General Settings-> Registration/Profile Fields
I created similar list fields in Mailchimp GENDER, AGERANGE, COUNTRY
Sharing the code that worked.
I added the following function to my theme functions.php
function my_filter($merge, $vars)
$user_id = $vars['user_id'];
$gender = get_user_field ("gender", $user_id);
$age = get_user_field ("age", $user_id);
$country = get_user_field ("country_code", $user_id);
$my_custom_merge_vars = array("GENDER" => $gender, "AGERANGE" => $age, "COUNTRY" =>$country);
return array_merge($merge, $my_custom_merge_vars);
Hope this spares some hours for somebody else trying to do the same. I guess this could be optimised by getting all the fields into an array once. But since this worked, I am going ahead with this.
This topic was modified 4 years, 1 month ago by Rahul Baji. Reason: correction1
This topic was modified 3 years, 4 months ago by Rahul Baji.