Restrict access to Drupal nodes, node types and menu items

28-Oct-2008
Filed under: Drupal, Drupal 5.x

If you want to restrict access to certain pages, or all pages of a certain type, on your Drupal website, I recommend 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.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

Comment spam will be deleted.

This includes any comment posted here for the sole purpose of increasing your page rank. You're wasting my time and your own.