Created
July 18, 2017 18:36
-
-
Save mmenavas/ca54e4b64af11404741c3908fd4f1604 to your computer and use it in GitHub Desktop.
Add role to users.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$users = array( | |
'username1', | |
'username2', | |
); | |
foreach ($users as $username) { | |
$user = user_load_by_name($username); | |
$role = user_role_load_by_name("event coordinator"); | |
$user->roles = $user->roles + array($role->rid => $role->name); | |
user_save($user); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment