3

Is there any way that I can use a custom PHP code to control the visibility (proper Drupal access) of a node?

Something similar to content access module, but instead of access control by role, I'd like to have access by PHP code so if it returns true, users can access that node, if not, the node will be access denied?

  • Sort of an answer but also sort of a comment: Examples project has an example that does this. Don't do it at hook_node_view() time. :-) api.drupal.org/api/examples/… – paul-m Nov 3 '12 at 19:14
1

You might be able to do that by using the HOOK_NODE_VIEW(). In my experience I have had great success using the ACL and content access modules as you can control the view, edit and delete function of the nodes by roles, but also a the node level you can specify what user(s) can have access and what type of access.

  • Sorry I had to add that I am using Drupal 6 in fact. ACL sounds promising, is there any document for that module on how to use its API? – Luca Nov 3 '12 at 18:20
  • ACL by itself will not give you much to work as it is just the set of APIs. After the intall the Content Access module is when you will start seeing the access control options in the content types creation form and on each node. Also be aware that when you install or uninstall ACL the permission table is rebuilt. – Emil Orol Nov 4 '12 at 17:38

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.