You are here

function user_has_role in Drupal 7

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

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]);
}