[support] block visibility based on role AND path

Nick Young nick_young at ncsu.edu
Mon Oct 6 12:49:33 UTC 2008


(Issue in Drupal 6)
I need a php snippet that allows me to display (or hide) a block based 
on whether the user logged in is a member of a certain role, and that 
they are browsing the site at a certain path. I am able to display a 
block based on one of these things, but not both.

IE:
I can display a block if the user is a member of a role.
I can display a block at a certain path (<site>/node/path/x)

However, if i combine the two pieces of php code, then if one of them 
returns true, the block shows. What i need is for it to check if the 
path is TRUE, and then also check for the role membership. I have tested 
the code externally to Drupal, to make sure the nested IF statements are 
working properly, and they are. It's almost as if Drupal sees the first 
TRUE, and then stops looking to see if there are multiple conditions to 
check for as well.

Any ideas? Thanks in advance.

........................................................................
Nick Young
Outreach, Communications & Consulting
Office of Information Technology
North Carolina State University
Box 7109, Raleigh 27695
Ph. 919.513.2716 | E-Mail: nick_young at ncsu.edu <mailto:nick_young at ncsu.edu>
........................................................................





More information about the support mailing list