You can configure Drupal block visibility under Admin -> Blocks -> Configure. One option is "expert mode" whereby you can write a snippet of PHP code. If it returns true, the block is shown, otherwise it is hidden.
Some relevant code that works:
<?php
global $user;
return ((in_array('writer', $user->roles))||($user->uid)==1);
?>The global $user variable contains info on the current Drupal user.
in_array('writer', $user->roles)) checks to see if the current user is in the group 'writer' and returns true if so.
($user->uid)==1) returns true if the user's ID is 1. In Drupal, this means they are the admin user.
Therefore this block is shown to anyone who is either the admin or has the role of a "writer".

Comments
Post new comment