i have made the following custom module, in order to prevent any user that belongs to group 1, be able to view or edit a node that belongs to group 2. Still if one knows the url of the node, manages to view it regardless of which group he belongs to, and more important, edit it. Any resemblance to any other question posted here is just a coincidence, also to mention that each node belongs to one and only group.

What am i doing wrong in below code?

     * Implements hook_node_access()
    function mymodule_node_access($node, $op, $account){
        if($op=='view' && isset($node->og_group_ref[und])){
            if($node_og_group_nid!=$user_og_group_nid) return NODE_ACCESS_DENY;
  • 1
    I'm wondering if this question is for the same site, with the same basic issue, that this other question is about? If so, shouldn't the contents of this question be appended to the first one? Jan 22, 2020 at 17:19
  • i would rather you made a meaningful comment. My question is about a custom module i have written. I do not see how your comment helps with my code.
    – ruse
    Jan 23, 2020 at 8:08
  • 1
    My comment was intended to help you. If your question is about the same site then you should do what I recommended. If it's not related to the first, then you really should say so. When I first saw your question, I assumed it was the same person asking about the same site, who created a new account to make it appear as if it wasn't. That would make it unlikely either question would be answered since most of the frequent users would assume the same thing. But if it was a coincidence, you needed to know about the first question, so I wrote my comment instead of just ignoring your quesrion. Jan 23, 2020 at 12:45


Your Answer

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

Browse other questions tagged or ask your own question.