Users have 'edit own content' permission for content type 'diary'. When viewing own diary node, I would like to present a simple checkbox to 'make private'. Then only that user can view the node.

I've looked at some options for doing this:

1) Write a module that uses hook_node_access() - overkill?

2) Perhaps an existing content access module provides a useful hook?

3) Create a 'private yes/no' field, then use Editablefields module to expose it on view. Then use theming layer to hide if set to 'yes'. - clunky?

I'm learning to write simple modules so perhaps a good learning opportunity here, but not sure where to start.

  • Upvoted question as I think it's a common problem.
    – Letharion
    Jan 2, 2012 at 21:57
  • Would unpublishing the node accomplish this?
    – Jimajamma
    Jan 3, 2012 at 3:08
  • Unpublishing the node is another potential method, though one of the objectives here is to give the node author control without expecting them to navigate through the node edit form.
    – pushka
    Jan 3, 2012 at 9:42

1 Answer 1


I think you should create the field as suggested in 3 regardless of which method you choose for authorizing users to view content. Your first suggestion seems reasonable. I would personally opt for method two, and use the Page Manager in Ctools. PM is a tool however, and as such requires both understanding and configuration to do what you ask. Your third option, hiding in the theme, seems wrong however.

  • Ah using conditional displays in Page Manager - I like that idea. Thanks.
    – pushka
    Jan 3, 2012 at 9:43
  • Note that using fields as "access-plugins", which would be my suggestion here, was commited to Ctools rather recently, and as such requires -dev. drupal.org/node/1300476
    – Letharion
    Jan 3, 2012 at 9:48
  • Thanks for the tip. I'm using the node_view system page to override the display of 'diary' content type. I don't think this page allows use of access settings/plugins, but I think I can use Selection Rules and use a PHP Code rule?
    – pushka
    Jan 3, 2012 at 12:32
  • Yes, you can absolutely do that, and most of the time, it's gonna work out well. I'm just not fond of any use of the PHP filter, as using it comes with a large number of problem. Selection rules are based on what ctools refers to as "access plugins", that's why I mention them. And the patch above, which I have only briefly tried myself, is supposed to allow any field to be used as an access plugin.
    – Letharion
    Jan 3, 2012 at 13:47

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.