Restrict access to Drupal nodes, node types and menu items

The information in this article applies to Drupal 5.

If you want to restrict access to certain pages (or indeed all pages of a certain content type), I'd recommend using the Content Access module. Unfortunately, the Content Access module fails to hide the menu item of a restricted page.

This means that your restricted page will still show up in your site's menu and visitors will be able to navigate to the page where they will be greeted with a rather unfriendly access denied error message. According to this bug report, it's down to a deficiency in Drupal itself and not something that's going to be fixed in the Content Access module. Happily, there is a solution that I will discuss below.

Of course, this behaviour might be exactly what you're after. If this is the case, I'd suggest using the LoginToboggan module, which (amongst many other useful features) will allow you to display a login form on the access denied page.

However if your menu is a mixture of links to restricted pages and links to views, you'll find that the Views module correctly hides the menu item of a view to users who do not have permission to access it. So you're left with half a menu, consisting only of links to your restricted pages.

In this case you can use the Remove Non-viewable Menu Items module to hide the menu items of your restricted pages. There's no configuration required, so just install it and watch your restricted menu items disappear.

NOTE: This article was first published on The Web Developer's Blog, which has now been discontinued.