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

modules/user/user.module, line 870

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.