1

I have a website with a couple of pages and organic group pages. I'm trying to deny access to one "basic page" for authenticated users. (I only want anonymous users to see the page). Every module I've downloaded seems to mess up my permissions and stuff set up for my other pages and views. Is there any simple way to do this?

I've tried content access and node privacy by role.

1
  • Content access should work for you, otherwise, Clive's answer will be the best way. Check this drupal.org/node/361112
    – Sithu
    Commented Sep 14, 2012 at 8:47

1 Answer 1

1

If you don't mind hard coding the node ID you could do this fairly easily in a custom module using hook_node_access():

function MYMODULE_node_access($node, $op, $account) {
  if ($node->nid == $node_id && $op == 'view' && $account->uid > 0) {
    return NODE_ACCESS_DENY;
  }
  return NODE_ACCESS_IGNORE;
}
8
  • 1
    This is the easier, and faster way.
    – avpaderno
    Commented Sep 13, 2012 at 21:51
  • That's perfect. I figure that a custom module would be the easiest way to go. I have never made a custom module, so I don't understand the code above entirely, but I appreciate the info. Just to make sure... the code above does what? Blocks authenticated users from a specific node? Or does it allow anonymous users to a specific node?
    – EGHDK
    Commented Sep 13, 2012 at 23:54
  • The if statement is basically "if the node id is a specific node id, and the current operation is to view the node, and the provided user has an id greater than zero (which a logged in user will), then deny access to the node. Otherwise ignore this hook implementation as it has no say in this op". Hope that makes sense :)
    – Clive
    Commented Sep 14, 2012 at 0:08
  • Great. Exactly what I needed. I appreciate it!
    – EGHDK
    Commented Sep 14, 2012 at 18:15
  • Hm... I put in my node number but it's not working. I'm not getting any complaints from drupal. But i can still access the page/tab.
    – EGHDK
    Commented Sep 23, 2012 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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