Sync and Exclude on User Role – github code NOT working
-
I want to exclude a certain user role when doing sync.
I used this exact code (only changing the name of my role to exclude):
https://github.com/ibericode/mc4wp-snippets/blob/master/add-ons/user-sync/exclude-roles.phpadd_filter( 'mailchimp_sync_should_sync_user', function( $sync, $user ) { // setup array of roles which should be excluded from Syncing. $excluded_roles = array( 'Inactive', 'some_other_role' ); // check each role foreach( $excluded_roles as $excluded_role ) { // do not synchronize user if it has the excluded role. if( in_array( $excluded_role, $user->roles ) ) { return false; } } // use default value (from settings) return $sync; }, 10, 2);
And it does not work, meaning, if a user has the above role(s), it is still synced. We do NOT want to synchronize user if it has the excluded role.
I could also exclude based on a meta_value if that would be easier??
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Sync and Exclude on User Role – github code NOT working’ is closed to new replies.