I have added a menu item to the Navigation menu block but I only want it displayed when a user logs in. How do I do this? It seems that by default, other items in this menu stay hidden until login (for example my account) so there must be a way to do this. I thought that maybe the Navigation menu block was 'special' in this sense so I checked out the custom menu block I've added thinking that I might move this item there. I cannot see how to do it for items in my custom menu either!
Any help would be appreciated.

Comments

aquaseal’s picture

http://drupal.org/node/13266 ... Hope that helps

Sam308’s picture

Also, take a look here:

http://drupal.org/node/46254

Sam Raheb (Sam308)

Raymondo’s picture

Thanks for the links. They both talk about hiding blocks. I only want to hide one menu item in a menu block. I'll do some code searching in the menu module and see what I can come up with.

edit: Well, it seems like I'd have manage the menu display myself which is rather daunting. For the moment, I've simply applied a login check on the page that that particular menu item takes you too. It's not a very satisfactory solution. I'd much rather that the menu item simply didn't appear until login, but it seems, for the time being, that drupal is not set up to handle this.

heine’s picture

What item are you trying to hide? One option is to disable the menu-item and then make a module that adds it, but only for logged in users.

After a chat with JoeyDay on IRC about showing a login link only to unregistered users I wrote a small module, perhaps you can use it as an example (the attached module only works in 4.7, the code in both 4.6 and 4.7).

--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.

Raymondo’s picture

I have a db attached to the drupal site. The menu item relates to that db. It's a lot like the 'my account' menu item for the site. It's where logged in users can add/update/delete there content in this db.
I'd like the item to only show up after login. Users who register on the site are (or will be when it's finished) automatically registered on the attached db - same username, password etc.
I'll try your idea of disabling it and enabling it at login. I'll have to remember to disable it again on logout. I have no idea how to do this but I'll dig through the code. There must be a definition of the internal menu somewhere, perhaps in drupal's db.
So far, this is only one of two aspects of drupal that frustrate me, the other being the yawning gap between text/titles and tables in the pages I've created. Drupal is otherwise a fantastic framework for what I'm trying to build.

Continental’s picture

How to hide a menu from anonymous users in 4.6? I created one menu item that shuld be show only to registered users in the Navigation menu. What should I change in 4.7 code and for my case?