Currently I want to keep my site slim without having to install big modules to do a small function. I know I can use the content_access module to restrict a user role to view a specific content type, but I was wondering how can this be done without any additional modules installed.

I have a content type of "widget" and I don't want it view-able by anonymous users. It should only be viewed by staff. How can you restrict/hide this content type from anonymous users without installing a module for it?

  • i ended up removing all the fields on full page display mode so users wont be able to see it. this lets me still use the fields in views which are restricted to staff – Patoshi パトシ Feb 17 '15 at 19:10

You can control node access using hook_node_access


 * Implements hook_node_access
function MY_MODULE_node_access($node, $op, $account) {

  $type = is_string($node) ? $node : $node->type;

  if ($type == 'type_of_interest') {
    // Require administer nodes permission to view
    if (($op == 'view') && (!user_access('administer nodes', $account))) {
      return NODE_ACCESS_DENY;


You could keep the nodes "unpublished". This would hide these nodes from anonymous users. And only internal folks would be able to view these nodes and no modules need to be installed.

  • This will not work. – DRUPWAY Feb 17 '15 at 5:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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