1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'XenForo Development Discussions' started by BobbyWibowo, Mar 22, 2016.

  1. BobbyWibowo

    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.
  2. BobbyWibowo

    BobbyWibowo Well-Known Member

  3. katsulynx

    katsulynx Well-Known Member

    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.
  4. Lawrence

    Lawrence Well-Known Member

    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: Apr 4, 2016

Share This Page