Title: Sync Role Name (with example code)
Last modified: August 31, 2016

---

# Sync Role Name (with example code)

 *  Resolved [Elliot Taylor](https://wordpress.org/support/users/raisonon/)
 * (@raisonon)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/sync-role-name-with-example-code/)
 * 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://wordpress.org/plugins/mailchimp-sync/](https://wordpress.org/plugins/mailchimp-sync/)

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

 *  Plugin Author [Danny van Kooten](https://wordpress.org/support/users/dvankooten/)
 * (@dvankooten)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/sync-role-name-with-example-code/#post-6911834)
 * 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](https://wordpress.org/support/users/raisonon/)
 * (@raisonon)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/sync-role-name-with-example-code/#post-6911838)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/mailchimp-sync_cfeefa.svg)
 * [MC4WP: Mailchimp User Sync](https://wordpress.org/plugins/mailchimp-sync/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/mailchimp-sync/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/mailchimp-sync/)
 * [Active Topics](https://wordpress.org/support/plugin/mailchimp-sync/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/mailchimp-sync/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/mailchimp-sync/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Elliot Taylor](https://wordpress.org/support/users/raisonon/)
 * Last activity: [10 years, 4 months ago](https://wordpress.org/support/topic/sync-role-name-with-example-code/#post-6911838)
 * Status: resolved