I've gotten my site to the point where most regular users are just going to make comments and posts in the forums. Therefore, they don't need the main navigation bar.

One option in "configuring" the Navigation block is to have it run when a box of PHP code returns true. Is there a magic set of PHP code to see if the person is a member of this or that role level?

I looked around the forums and found some things, but most seemed to be applicable to 4.6 and creating a custom module. I'd love to use less non-custom and more core settings.

Thanks in advance for your help.

Dan

Comments

blarg’s picture

Not sure if this fits what you need, but using the Menu module you can just turn off the things "normal users" don't need and the admin would still have full access to the entire menu.

Do you need more fine grained control over this?

pwolanin’s picture

I previously put together some links to drupal pages covering this topic:

http://drupal.org/node/52142#comment-98381

As an example, the code below could be used to only show a block to users with the role "content adder":

global $user;
if (in_array('content adder',$user->roles)) {
  return TRUE;
}
else {
return FALSE;
}

---
Work: BioRAFT

dandaman’s picture

Thanks, pwolanin!

I guess I have to learn a bit about how to find what I need on drupal.org. It's usually here, but just not easily visible.

That snippet of code did the trick. You're the best.

Dan "da Man"
Webmaster
http://cMusicWeb.com/
http://da-Man.com/

Dan "da Man" Ficker
http://da-Man.com/

adoucette’s picture

I would like to put something like this in the 'page specific visibility settings' of administer -> block so that a certain block will only be shown to certain roles.
Under "Show if the following PHP code returns TRUE (PHP-mode, experts only)." I have put the following code:

global $user;
if (in_array('administrator',$user->roles)) {
  return TRUE;
}
else if (in_array('meduser',$user->roles)) {
  return TRUE;
}
else {
return FALSE;
}

But it doesn't work right for me. I still get the block for every user (even unauthenticated). What have I done wrong?
TIA,
Ariel

adoucette’s picture

Here's a post that answers my question.
http://drupal.org/node/51325#comment-124601
Ariel