Hello,

I would like to add a menu item just above the "create content" one. The problem is: when I do this it is visible even when I'm not logged in.

How do I create a menu item that can only be seen once you're logged in?

Thanks!
Ben

Comments

nancydru’s picture

kailash0009’s picture

Just go to navigation block and there is set visibility option check radio button show block if PHP code return true

then type code which will check user->role==admin
thats it

global $user;
if ($user->uid == 1){
  return TRUE;
} else {
  return FALSE;
}

in this code i only got one admin with user id =1
so the menu will b available to admin
n i created a different block for users

kailash0009’s picture

Just go to navigation block and there is set visibility option check radio button show block if PHP code return true

then type code which will check user->role==admin
thats it

global $user;
if ($user->uid == 1){
  return TRUE;
} else {
  return FALSE;
}

in this code i only got one admin with user id =1
so the menu will b available to admin
n i created a different block for users

shyamala’s picture

Goto
http://www.mysite.com/?q=admin/build/block.

Configure the navigation menu.
Role specific visibility settings and check the roles you want the menu block to be displayed.

Shyamala
Team Leader (http://www.netlinkindia.com)

nancydru’s picture

itangalo’s picture

Concerning the roles who should be able to submit content: Do you want it to be you only, admins only, or everyone who is logged in to your site?
Menu per role still does the job, but if you want it to be you only, the code snippet above is probably much quicker.

//Johan Falk, Sweden

itangalo’s picture

Menu per role allows not only blocks to be visible to specified roles only, but also to make menu items visible to chosen roles.
However, this is done through the menu administration, and not the blocks administration.

(I'm pretty sure it's the Menu per role that allows me to make these customizations at my Drupal site. Please tell me if I'm wrong, and I'll try to look up which module it is that does the trick.)

I hope this helps.

//Johan Falk, Sweden

PS: And, yeah, you'll need to have an admin role in order to restrict access to that role only. It may seem silly if you're only using the very first user login (which automatically have access to everything), but unless you restrict visibility to at least one role, items/blocks will be visible to everyone.