Check Guests' View Permission for a Node (Template?)

BobbyWibowo

Well-known member
Is it possible to use a template conditional to check whether guests (only) have the permission to view a current node? Well, if there's no template conditional, a way to do it from a listener is fine as well.
Thanks in advance.
 
Nothing I could spontaneously think of. You'd have to check the permissions of all groups in that case. It would probably be easier to just check if the forum-id is in a given list if you want to keep it simple or create a helper that iterates over all groups.
 
Is it possible to use a template conditional to check whether guests (only) have the permission to view a current node? Well, if there's no template conditional, a way to do it from a listener is fine as well.
Thanks in advance.

What got me in your question is view permission for current node. If a guest is viewing a node then they must have permission. Are you referring to if the guest has permission to view child-nodes of the current node? If you are, then you would need to create a listener for controller public and check the view permissions for each child node (or if the current node only contains threads, then check for the thread view permission for the current node).

A much easier and more efficient way for checking child nodes permission is to create a new forum permission called something like: View child-nodes, and set to revoke for the unregistered group. Now all your listener needs to do is to check that permission for the current node. If not true, either throw the standard error message, or add a new message to the $params to be outputted to the guest to read.
 
Last edited:
Top Bottom