Lightweight way to check to see if another user has a role
Something like:

function MYMODULE_get_user_roles($uid) {
  $roles = &amp;drupal_static(__FUNCTION__, array());

  if (!isset($roles[$uid])) {
    $query = db_select('role', 'r')
      -&gt;fields('r', array('rid', 'name'))
      -&gt;condition('ur.uid', $uid);

    $query-&gt;join('users_roles', 'ur', 'ur.rid = r.rid');

    $roles[$uid] = $query-&gt;execute()-&gt;fetchAllKeyed();
  }

  return $roles[$uid];
}


You might want to add static caching to that if you plan to call it more than once for any single user during a single page build.