function user_has_role

7.x misc.inc user_has_role($role, $account = NULL)
6.x misc.inc user_has_role($role, $account = NULL)
4.x misc.inc user_has_role($role)
5.x misc.inc user_has_role($role, $account = NULL)

Does the user have the specified role?

File

includes/misc.inc, line 2920
This file contains misc functions for FlightPath

Code

function user_has_role($role, $account = NULL) {
  global $user;

  if ($account == NULL) {
    $account = $user;
  }

  // Admin always = TRUE
  if ($account->id == 1) {
    return TRUE;
  }

  // Check for other users...
  if (in_array($role, $account->roles)) {
    return TRUE;
  }

  return FALSE;

}