• Hello and good day.

    I had wanted to sync the Group name a customer is in with MailChimp for WordPress Plugin using their extension.

    This is the example code I had gotten here: https://kb.mc4wp.com/syncing-custom-user-fields-mailchimp/#advanced-fields

    add_filter( ‘mailchimp_sync_user_data’, function( $data, $user ) {
    $data[‘MERGETAG’] = $user->field_name;
    return $data;
    }, 10, 2 );

    My question is how do I find the filed name of a group to use in MailChimp Sync.

    Thank you and have an amazing day!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi Deyson,

    In case this is still requested, here is a solution you can use.
    First you need to get all the groups the user belongs to:

    $groups_user = new Groups_User( get_current_user_id() );
    $user_groups = $groups_user->groups;
    $user_group_ids = $groups_user->group_ids;
    $user_group_ids_deep = $groups_user->group_ids_deep;

    And afterwards once you have the group ids, you can get the group names by looping the following like this:

    $each_group = Groups_group::read( $each_group_id );
    $each_group_name = $each_group->name;

    Kind regards,
    George

    Thread Starter deyson

    (@deyson)

    Hi! Thank you. Do I add this code to the code provided in the link in the original post?

    Thank you ??

    Hi Deyson,

    Yes you need to add it there.
    Please keep in mind that there are further elements needed in order for this to function properly. Assuming that this is the correct hook to use, you need for example a loop to check each one of the group ids fetched.

    FYI, in order to implement it you need to have strong PHP and WordPress API skills, otherwise it’s better to consult an experienced developer.

    Kind regards,
    George

    Thread Starter deyson

    (@deyson)

    Thank you! I will look for a developer. Where do you recommend that I look that could understand your plugin? Thank you ??

    Hi Deyson,

    A good place for this would be https://jobs.wordpress.net/.

    Cheers,
    George

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Sync with Mailchimp for WordPress’ is closed to new replies.