How can I allow only specific nodes to be displayed based on user roles?

Basically, I do not want to allow nodes to be accessed by users of some specific role.

  • 3
    Not sure why they closed your question, it's a good question. And for anyone who might be interested, I always solve these types of problems by making a custom module and overriding api.drupal.org/api/drupal/modules%21node%21node.api.php/… ... full control, no overheads in the form of massive modules, way easier and more reliable. Sep 18, 2015 at 7:29
  • 1
    @coderama It's a bit broad, without the OP showing what they tried so far. Such questions get broad answers that probably will not help future users.
    – apaderno
    Aug 17, 2018 at 19:46

2 Answers 2


Have you tried the content access module

This module allows you to manage permissions for content types by role and author. It allows you to specifiy custom view, edit and delete permissions for each content type. Optionally you can enable per content access settings, so you can customize the access for each content node.

  • 1
    If you don't need node-based permissions then a simpler module is the node view permissions module which controls access based only on content type and user role.
    – jevon
    Oct 31, 2013 at 3:45
  • 1
    This module is beta for Drupal 7
    – Toby Allen
    Oct 20, 2014 at 11:25

What you're talking about is Drupal node access control, which is a huge subject.

The core's built-in support for node access control is rather coarse, and to control access to view a node by role, you must use some sort of node access control module.

There is a page at Drupal.org listing all node access modules, with a capsule review of each. I suggest you take a look at that page to see if you can find a suitable module to control access based upon roles.

When working with access control, it helps to understand how Drupal access control modules actually work, here is a quick description:

  1. Users granted permission to administer nodes are never restricted by node access control. Users who do not have permission to View published content can never be granted access by a node access module. Only users who have 'access content' and not 'administer nodes' are eligible for the wild world of node access module control.

  2. Node access control in Drupal is as a rule additive. This means that any module doing access control in accordance with the “the Drupal philosophy” should only allow access, not deny it. An administrator who wants to fine tune access to a node must first make sure nobody has access, and then add access grants to anyone that shall have access.

This means that it may be rather cumbersome to restrict access to individual with a module like Content Access, since you must start by denying everyone access, and then add it back to those nodes you don't want restricted. However, I think it is the best option if you really need to do it node by node. Its primary resolution is content types, but it allows you to override this for single nodes.

Unfortunately, you shall not be able to use Deny access since it only works on content types, with no override for individual nodes.

NB: Using more than one node access module is not recommended.

Note that if you can change your requirements so that you can use content type as your basic unit for node access control, then Deny access would be ideal. For instance, if you have a role "student" and you want to deny access to nodes with answers, then you can create a content type "Answer" (which can just be a clone of the default "Article") and Deny access will take care of protecting all nodes of the type "Answer" from being viewed by the role "student".

  • 1
    basically i do not want to allow nodes to be accessed by users of some specific role is this too tough to implement ?
    – harshal
    Aug 21, 2013 at 9:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.