• Hi, in another support ticket you give an insight into how to accomplish this, see: https://www.ads-software.com/support/topic/more-than-one-list-for-different-user-types/

    I’ve built upon that code, but somehow can’t seem to get it to work. Am I missing something?

    add_filter('rusac_fetch_registered_user_data', 'nmr_ac_sync_lists', 10, 2);
    function nmr_ac_sync_lists($user_data, $user_id) {
    	$user = get_userdata( $user_id );
    	$roles = $user->roles;
    	
    	if ( in_array( 'member', $roles ) ) {
    		$user_data['p[35]'] = 35;
    	}
    	elseif( in_array( 'prospect', $roles ) ) {
    		$user_data['p[36]'] = 36;
    	}
    	elseif( in_array( 'customer', $roles ) ) {
    		$user_data['p[37]'] = 37;
    	}
    	return $user_data;
    }

    Any help would be much appreciated. Thanks.

    UPDATE: Problem with original code found. Code has been updated to work. ??

    • This topic was modified 3 years, 2 months ago by semmtex.
    • This topic was modified 3 years, 2 months ago by semmtex.
Viewing 1 replies (of 1 total)
  • Thread Starter semmtex

    (@semmtex)

    Ok, I found my mistake (working code updated in first post). It now almost works as expected. As in, it adds to the right list depending on user role. However, it also adds the user to the default list. This shouldn’t happen. Any insight?

Viewing 1 replies (of 1 total)
  • The topic ‘One list per user role’ is closed to new replies.