summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/user/user.module20
1 files changed, 20 insertions, 0 deletions
diff --git a/modules/user/user.module b/modules/user/user.module
index bdfd36fa3..d74ed2f40 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -849,6 +849,26 @@ function user_is_blocked($name) {
}
/**
+ * Checks if a user has a role.
+ *
+ * @param int $rid
+ * A role ID.
+ *
+ * @param object|null $account
+ * (optional) A user account. Defaults to the current user.
+ *
+ * @return bool
+ * TRUE if the user has the role, or FALSE if not.
+ */
+function user_has_role($rid, $account = NULL) {
+ if (!$account) {
+ $account = $GLOBALS['user'];
+ }
+
+ return isset($account->roles[$rid]);
+}
+
+/**
* Implements hook_permission().
*/
function user_permission() {