block restrict depending on role I use this snippet to restrict block visibility from administrator 

&lt;?php
global $user;
if (user_access('access administration pages') || ($user-&gt;uid == 6)) {
  return FALSE;
} else {
  return TRUE;
}
?&gt;


I also want to restrict this block from role 6. However, it does not work. Can somebody help?

Thank you
// Check to see if $user has the administrator role.
  if (in_array('administrator', array_values($user-&gt;roles))) {
    // Do something.
  }


Replace "administrator" with the role name you want to check.

EDIT:

If you want to check for role id's use below code.

global $user;
$role_ids = array_keys($user-&gt;roles);
if (in_array(6, $role_ids)) {
  // Do something
}


In your case

&lt;?php
global $user;
$role_ids = array_keys($user-&gt;roles);
if (user_access('access administration pages') || (in_array(6, $role_ids))) {
  return FALSE;
} else {
  return TRUE;
}
?&gt;