[support] block visibility based on role AND path

bharani kumar bharanikumariyerphp at gmail.com
Mon Oct 6 13:34:09 UTC 2008


May  this is clue,

If you know  member id,  ,

Go to block  configure

select  " Show if the following PHP code returns TRUE (PHP-mode, experts
only). "

and write the code

global $user

$userid=$user->uid;
if($userid ==10 || $userid ==10  ){

return TRUE;

}
else{

return FALSE;
}


On Mon, Oct 6, 2008 at 6:19 PM, Nick Young <nick_young at ncsu.edu> wrote:

> (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
> >
> ........................................................................
>
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20081006/6d413ca2/attachment-0001.htm 


More information about the support mailing list