Multiple roles to a user
-
Hi.
How can i add multiple roles to a user via code.?
In user’s login hook, I add the code below.$roles = array( 'role1', 'role2', 'role3', 'role4' ); foreach ($roles as $key => $role) { wp_update_user( array( 'ID' => $user_id, //User logged 'role' => $role //From array $roles )); }
But the user only remains with the last role in the iteration.
Any sugestion?
Thanks.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Multiple roles to a user’ is closed to new replies.