Check current user for given roles in Drupal 7

Last updated on 03/04/2016

Update

You may consider using the new API function added in Drupal 7.36

user_has_role()

This is a wrapper function:

/**
 * Check current/given user for given roles.
 */
function role_access($roles, $account = NULL) {
  if (!is_array($roles) || empty($roles)) {
    return FALSE;
  }
 
  if (!$account) {
    $account = $GLOBALS ['user'];
  }
 
  foreach ($roles as $role) {
    if (in_array($role, $user->roles)) {
      return TRUE;
    }
  }
}