Adding Groups to Mailchimp Sync
-
Hello,
I’m developing a website for my company and we’re trying to sync the assigned group data in buddy press with the user so when we go into mailchimp we can sort/partition our lists in mailchimp by the corresponding group.
The code we’re using to sync all the other data in extended profile is here, but my concern is that we can’t pull the group the same way because it’s not something that gets added in the extended profile. I’m almost certain that I can’t pull the group with these parameters because when i look in the database, there’s no user-ID tied to any group. However, when i go into buddypress groups there’s users assigned to them.
This is the function we’re using to sync:
add_filter( ‘mailchimp_sync_user_data’, ‘mailchimp_buddypress’, 10, 2 );
//Write the function
function mailchimp_buddypress( $data, $user ) {//Get user ID
$user_id = $user->ID;// Store Xprofile fields in the $data variable
$data[‘JOBTITLE’] = xprofile_get_field_data( 11 , $user_id );
$data[‘ORG’] = xprofile_get_field_data( 12 , $user_id );
$data[‘CITY’] = xprofile_get_field_data( 36 , $user_id );
$data[‘STATE’] = xprofile_get_field_data( 16 , $user_id );
$data[‘COUNTRY’] = xprofile_get_field_data( 18 , $user_id );
$data[‘PHONE’] = xprofile_get_field_data( 19 , $user_id );
$data[‘SALUTATION’] = xprofile_get_field_data( 3 , $user_id );
$data[‘GROUP’] = bp_get_current_group_id( 1 , $user_id );
//Return the data
return $data;}
Right now the last line “$data[‘GROUP’] = bp_get_current_group_id( 1 , $user_id );” outputs a “0”.
Thank you for reading! Hoping someone on here can help me.
- You must be logged in to reply to this topic.