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.

  • Content access should work for you, otherwise, Clive's answer will be the best way. Check this drupal.org/node/361112 – Sithu Sep 14 '12 at 8:47
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;
}
  • 1
    This is the easier, and faster way. – kiamlaluno Sep 13 '12 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 Sep 13 '12 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 Sep 14 '12 at 0:08
  • Great. Exactly what I needed. I appreciate it! – EGHDK Sep 14 '12 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 Sep 23 '12 at 2:45

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.