Because all the functionality is locked down to user account holders on one site, I don't want to provide the navigation block as each link then just leads to an access denied page. How can I make the navigation block only available to logged in users?

Comments

JesusAddict3791’s picture

Try unchecking Access Content for anonymous users in your access settings. It's under Node Module. That should keep them from seeing anything before they log in.

Uwe Hermann’s picture

richardhall’s picture

Erm no, whilst I wan't the navigation menu to be invisible I still want all the pages to be shown to anonymous users. The navigation menu should only show if a user is logged in..

I've basically rigged it now to do what I want but its not an ideal solution.

Uwe Hermann’s picture

sangamreddi’s picture

Just use a php script in your theme i;e page.tpl.php

global $user;
if ($user->uid) :
Your navigation block here
endif;

this script checks whether a user logged in or not iflogged in it returns the navigation block. if not logged in returns nothing.

Sunny
www.gleez.com

sangamreddi’s picture

global $user;
$output = '';
if (is_array($user->roles) && in_array('Admin',$user->roles)) {
  $block = user_block('view', 1);
  $output .=  $block['content'];
}
return $output;

Not: I have admin role so i defined ADMIN there.

Creat a custom block and put the above code in it and select php as the input format and save.

just check it for other examples
http://drupal.org/node/13266

Sunny
www.gleez.com

NaSPA1’s picture

Like many others, I too want to suppress the navigation block for anonymous users. However, while many of the custom block solutions recommended here and other threads work to a degree - there's a couple of undesirable side effects:

1) For all of the custom block solutions, the anonymous user will still see the "block header" without the content.

2) For logged in users, it seems the various solutions lose the "personalization" of the block changing the header/block title to the username...

Anyone have a 4.6.x solution that makes the block totally disappear for anonymous users AND showing the "personalized" menu for logged in users?

Radi

ica’s picture

Does any of code examples here not present any block at all if user not logged in.. _ as content is full with instead of an empty space of blocks area on the theme

current options on User specific block visibility settings does not provide this

Custom visibility settings:
- 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.
- Allow individual users to customize the visibility of this block in their account settings.

pepeek’s picture

Add this to function to your template.php file and replace YOUR_THEME with your theme name:

function YOUR_THEME_block($block) {
  global $user;
  if ($block->module.'-'.$block->delta == 'user-1' && !$user->uid) {
    return;
  }
  else {
    return theme_block($block);
  }
}