For Drupal 4.6.*

How do I to prevent navigation block appearing for anonymous,
only appear for authenticated users?

I searche and found http://drupal.org/node/12445#comment-47197
but could not determin how to apply with recent, drupal 4.6.2

Comments

webengr’s picture

I created a new block with the below php, enabled, and then disabled the Navigation block. This works so long as the navigation block does not have any additional menus, they are not blocked from anonymous users with this method.

How do you prevent anonymous from seeing the additional menus?

global $user;
if ($user->uid) {
if ($menu = theme_menu_tree()) {
   $menu = "<div class=\"menu\">". $menu . "</div>";
   return $menu;
}
}
else {return;}
webengr’s picture

http://drupaldocs.org/api/4.6/function/theme_menu_tree

The Navigation menu is PID=1

I thought if add yet another block using theme_menu_tree and modify by putting the a different PID in the theme_menu_tree($pid=0)

but that went fubar... looking at the database, when we create additional menus in the navigation/menu module it assigns them the PID=0 so if we use $pid=0 that shows all the menus including navigation.

this menu thing is SO DARN COMPLEX!!!!

uncle.. just have to move all into one menu to be able to prevent unauthenticated(anonymous) users from seeing additional menus that happen to be PID=0

or do own block or find another block code and put the if ($user->uid) rather than fooling with the menu table... its just so complex for now it can't be easily used for this application.
blew the KISS principle to heck

dww’s picture

i wrote a patch to the 4.6 version of block.module that allows site admins to just select via checkboxes what roles should be able to view any given block. see http://drupal.org/node/49154 for details. also, this functionality will be added to 4.7 sometime soon (see http://drupal.org/node/18018 for info on that discussion).

___________________
3281d Consulting