• Resolved Elliot Taylor

    (@raisonon)


    Love the option to sync user_meta with the list.

    Please could you add the option to sync the user_role name into MailChimp.

    Eg. If user_role = customer then we can push this into a field in MailChimp.

    This would be super helpful.

    I saw this code from another post:

    add_filter( 'mailchimp_sync_user_data', function( $data, $user ) {
        $data['WEBSITE'] = $user->user_url;
        return $data;
    }, 10, 2 );

    Can you confirm we can amend as follows for an interim solution:

    add_filter( 'mailchimp_sync_user_data', function( $data, $user ) {
    
    	$user_roles = $user->roles;
    	$user_role = array_shift($user_roles);
    
        $data['ROLE'] = $user_role;
        return $data;
    }, 10, 2 );

    https://ww.wp.xz.cn/plugins/mailchimp-sync/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Elliot,

    Actually, we have code set-up for that in the plugin already.

    You can simply use role in the Field Map (in the settings) to do this for you. You’ll get the translated user role, in case you’re running a non-English site.

    That said, using the mailchimp_sync_user_data filter and grabbing the value (any value) yourself is just as solid!

    Hope that helps. If not, let me know!

    Thread Starter Elliot Taylor

    (@raisonon)

    Well that was a lot easier than I was expecting. 🙂

    Thanks Danny!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Sync Role Name (with example code)’ is closed to new replies.