PHP Block for Custom Role under Drupal 6

Submitted by n8coder on Mon, 04/26/2010 - 11:33

Sometimes we need a block for just some users or a group of our websites. Under Drupal we can create a user group(role) and check current logges users role to give that user access or not. In this example I named it 'my_custom_role', but you can name it what ever you want ie: editor, moderator, privileged_customers, clients etc...

global $user;
if (in_array('my_custom_role',$user->roles)) {
return TRUE; // or print any content for my_custom_role
else {
return FALSE; // or print any content for other users