Show only for specific role?

heather - May 8, 2008 - 10:47

There is a PHP snippet which tests if the user logged in is of a specific role, but only for version 4.x
http://drupal.org/node/13266

How would I update this for Drupal 5.x?

<?php
global $user;
$output = '';
if (
in_array('admin user',$user->roles)) {
  
$output .= '<i>A block for admin users</i>';
  
$output .= '<ul>';
  
$output .= '<li><a href=/"?q=Admin/">Administration interface</a></li>';
  
$output .= '</ul>';
}
return
$output;
?>

I'll add it to the handbook, if someone can help?

Trytac_litehidden_contentm

Hetta - May 8, 2008 - 17:22

Try
tac_lite
hidden_content
menu_per_role
or any of the other modules which do that for you.

Oh wait - a block? Just clicky
[x] show for this particular user
and don't clicky
[x] anonymous access
in the admin -> block -> configure
settings.

thanks for the suggestions

heather - May 8, 2008 - 19:59

ah it's not actually for a block, it's just a little message i want to show for a specific user role.

http://drupal.org/project/menu_per_role

that might work, but i don't like the hacky method of the patch... i'd like to install as few modules as possible...

just want something to appear for a specific user role in the page template, so it's not a node actually. or a block.

i guess i could make it one? then include.. but i thought there must be a way to get that snippet code to work in 5.x... i just don't know myself what is wrong.

hidden_content is what you

Hetta - May 9, 2008 - 05:14

hidden_content is what you want.

 
 

Drupal is a registered trademark of Dries Buytaert.