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

Implemented Method to check permissions in a template

Discussion in 'Closed Suggestions' started by xf_phantom, Jul 10, 2013.

  1. xf_phantom

    xf_phantom Well-Known Member

    Since we don't "need" to use template hooks anymore, it would be really cool if we could check the $visitor permissions in the template too.

    Because of the missing template hook code, i would need to use the proxy class system to extend the controller to attach only
    $parentReturn->params['canViewFoo'] = XenForo_Visitor::getInstance()->hasPermission('my_addon','view');
    Would be nice to avoid the overhead and be able to check the permission direct in the template
  2. Chris D

    Chris D XenForo Developer Staff Member

    You can already do this. The visitor object contains all of the unserialized permissions:

    <xen:if is="{$visitor.permissions.group.permission}">
    Where group is the permissions group, eg forum and permission is the actual permission eg view.
    xf_phantom likes this.

Share This Page