You are here

function _administerusersbyrole_can_delete_user in Administer Users by Role 5

Same name and namespace in other branches
  1. 6 administerusersbyrole.module \_administerusersbyrole_can_delete_user()
2 calls to _administerusersbyrole_can_delete_user()
administerusersbyrole_form_alter in ./administerusersbyrole.module
administerusersbyrole_menu in ./administerusersbyrole.module

File

./administerusersbyrole.module, line 78
Allows users with 'administer users' permission and a role (specified in 'Access control') to edit/delete other users with a specified role. If the user being edited has multiple roles, the user doing the editing must have…

Code

function _administerusersbyrole_can_delete_user($account) {
  if ($account->uid == 1) {
    return FALSE;
  }
  foreach ($account->roles as $rid => $role) {
    if ($rid === DRUPAL_AUTHENTICATED_RID) {
      continue;
    }
    if (!user_access('delete users with role ' . $role)) {
      return FALSE;
    }
  }
  return TRUE;
}