function user_has_role

Checks if a user has a role.

Parameters

int $rid: A role ID.

object|null $account: (optional) A user account. Defaults to the current user.

Return value

bool TRUE if the user has the role, or FALSE if not.

File

drupal/modules/user/user.module, line 861
Enables the user registration and login system.

Code

function user_has_role($rid, $account = NULL) {
  if (!$account) {
    $account = $GLOBALS['user'];
  }
  return isset($account->roles[$rid]);
}