What I'm trying to accomplish is that I'm, at first, creating a new user into my network.
wp_create_user('newuser', 'password', 'firstname.lastname@example.org');
At this point, the
newuser's role is a subscriber (in network) - now I should move this user into subsite, and change its role as editor. So it would be a subscriber in my network, but an editor in the subsite.
$user = get_user_by('login', 'newuser'); add_user_to_blog( 2, $user->ID, 'editor' );
Logically, this should work, right? But for some reason, the user's role array is empty (in the subsite, in the network its still subscriber as it should be), even that in the subsite's dashboard it shows "Editor". I have also tried to change the role afterward but the role array stays empty.
What I'm missing here?