function drush_user_add_role

8.0.x user.drush.inc drush_user_add_role($role, $users = '')
6.x user.drush.inc drush_user_add_role($role, $users = '')
7.x user.drush.inc drush_user_add_role($role, $users = '')
4.x user.drush.inc drush_user_add_role($role, $users = '')
5.x user.drush.inc drush_user_add_role($role, $users = '')
master user.drush.inc drush_user_add_role($role, $users = '')

Add a role to the specified user accounts.

File

commands/user/user.drush.inc, line 280
Drush User Management commands

Code

function drush_user_add_role($role, $users = '') {
  // If role is not found, an exception gets thrown and handled by command invoke.
  $role_object = drush_role_get_class($role);
  $userlist = new UserList($users);
  $userlist->each('addRole', array($role_object->rid));
  drush_log(dt('Added role !role role to !users', array('!role' => $role, '!users' => $userlist->names())), LogLevel::SUCCESS);
}