• Resolved nickpagz

    (@npagazani)


    Hi Folks,

    Has anyone had any luck using the first section of code at https://github.com/ibericode/mc4wp-snippets/blob/master/add-ons/user-sync/groupings-based-on-role.php

    I have two user roles I am trying to sync with an interest group in a MC list and came across the code and a few posts in this support forum. I’ve copied the code and put it in my child theme’s function.php, but it doesn’t seem to work. I’ve tried a manual sync, but still nothing.

    Here’s my code:
    add_filter( ‘mailchimp_sync_subscriber_data’, function( $data, $user ) {
    $data->interests[ ‘a7d0f75cda’ ] = in_array( ‘Candidate’, $user->roles );
    $data->interests[ ’35fd830a28′ ] = in_array( ‘Employer’, $user->roles );
    //you can repeat this line for more groups / roles.

    //finally return the data
    return $data;
    }, 14, 2 );

    When I ran the manual sync it went through all the users and reported a successful update, but nothing changed in my MC list.

    Any help would be greatly appreciated.
    Thanks,
    Nick

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Lap

    (@lapzor)

    Please use the slug instead of the name. A slug can’t have capital letters in it.

    Thread Starter nickpagz

    (@npagazani)

    Ah! Rookie mistake. I’ve fixed and run a test, seems to be working now.
    Thanks!

    berkmh

    (@berkmh)

    @npagazani how were you able to sync the new list? I have the code in functions.php but when I hit sync its only pulling from the list in the plugin settings?

    Thread Starter nickpagz

    (@npagazani)

    Hi @berkmh, I’m not sure I understand the question. I only have one list in my MC account and was syncing with it already. I then added a new interest group to the list which corresponded with the WP user type, and hence needed this code to sync my user role to the options in the interest group.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Syncing multiple user roles to MC interest group’ is closed to new replies.