I went into adminster>blocks>navigation block configuration and I have 3 options:

-Users cannot control whether or not they see this block.
-Show this block by default, but let individual users hide it.
-Hide this block by default but let individual users show it.

But what I would like to do is have the nav block off when the user is not logged in. So for someone simply browsing the site, they wouldn't see the navigation block unless they created an account and logged in.

Can anyone help me with this?

Thanks

F.Q.

Comments

bjornarneson’s picture

You might trying to enable menu module, and disable any menu items that would be visible to an anonymous user. If you can strip out all of the block content for anonymous users, I don't think that the block will display.

Of course, the menu items that you disabled will not be available to either anonymous or authenticated users...

--
Bjorn | choirgeek.com

larry’s picture

Try this thread http://drupal.org/node/13013. I believe this should work for you.

larry

--There are no Kangaroos in Austria--

AndrewE’s picture

Thanks for the links, but the suggestions there are for 4.5 and before, I'm using 4.6 Also I am not good a PHP so writing my own modules or patching and stuff is very difficult for me.

I guess I'm just going to have to live with that navigation bar always on for the time being. Unless there is an easy way of doing it.

mechanical i

larry’s picture

Ok. This is the easy way. Open the user module in any editor of your choice...'Notepad' on windows for example. Either go to line 524 or search for the phrase 'case 1:'. Underneath this put 'if (!$user->uid) return;'. Here is 'before' and 'after' shots.

before:

return $block;

      case 1:
        if ($menu = theme('menu_tree')) {
           $block['subject'] = $user->uid ? substr($user->name, 0, 15) : t('Navigation');
           $block['content'] = '<div class="menu">'. $menu .'</div>';
        }
        return $block;

      case 2:

after:

return $block;

      case 1:
      if (!$user->uid) return;
        if ($menu = theme('menu_tree')) {
           $block['subject'] = $user->uid ? substr($user->name, 0, 15) : t('Navigation');
           $block['content'] = '<div class="menu">'. $menu .'</div>';
        }
        return $block;

      case 2:

save the changes. Boom, you've just gotten what you wanted. Hope this helps.

larry

--There are no Kangaroos in Austria--

AndrewE’s picture

Thank you so much for the tip. It worked straight off the bat!

It looks much tidier now.

F.Q.

TGR- a writer's space

larry’s picture

cheers.

larry

--There are no Kangaroos in Austria--

webmestre@www.coll-vallcarca.net’s picture

Hi,

I have tested it on 4.6.2 and it ran!!!

Now only registered users have acces to the lasts posts!!!

Thanks a lot!!!

zoinks’s picture

I was searching around for this answer as well. For some reason one of my admin menu items started popping up on non-registered user pages. This cleared it right up! THANKS

zoinks’s picture

Actually, it only worked partway, knocking out the admin completely for non-admins. For a more comprehensive solution, see the code mod I came up with....

http://drupal.org/node/34677

...or if you'd rather not muck with the core code, try tclineks' solution...

http://drupal.org/node/38427