These days Drupal is my life and spending all the research and work on it only. So came across another interesting problem and it’s solution.


The problem is: I was supposed to show custom menu to all the users for my web-site and main navigation menu should not be visible to all the users.

The solution: Go to administer -> Site building -> Blocks and then select the configuration link of Navigation menu. This will open up the configuration page. Now go down to Show block on specific pages. Now select the radio, which says “Show if the following PHP code returns TRUE (PHP-mode, experts only)” and add these code in the text-area below:


global $user;
return (($user->uid == 1) || ((is_array($user->roles)) && (in_array(“Model”, $user->roles))));
Here $user->uid is being compared for a specific user, in my case admin of the site and $user->roles is being compared for some role, for which the menu is supposed to be shown, in my case
Model.


Leave a Reply

Your email address will not be published. Required fields are marked *