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

Usergroup Permissions

Discussion in 'XenForo Development Discussions' started by Mythotical, Aug 19, 2011.

  1. Mythotical

    Mythotical Well-Known Member

    How can I call user group permissions in an add-on? I am looking for the 'clean' way of doing it so that all code is consistent.

    Thanks
     
  2. Mythotical

    Mythotical Well-Known Member

    I know not 24 hours but figured if peeps see 1 reply they may respond. So anyone have any ideas?
     
  3. James

    James Well-Known Member

    It depends how you want to call them. You can use XenForo_Permission::hasPermission() to check if a user has a permission.
     
  4. Mythotical

    Mythotical Well-Known Member

    Well I want to set it up in the file and use say $canViewShop so would I do this:
    PHP:
    $canViewShop XenForo_Permission::hasPermission('xshop''canViewShop');
     
  5. James

    James Well-Known Member

    You can do it this way:
    PHP:
    XenForo_Visitor::getInstance()->hasPermission('xshop''canViewShop'))
    or this way:
    PHP:
    XenForo_Permission::hasPermission($user['permissions'], "xshop""canViewShop");
    replacing $user['permissions'] with an array of the current user's permissions.
     
    Alien likes this.
  6. Mythotical

    Mythotical Well-Known Member

    I'll do the first way, its shorter. :D

    Thanks for the help James, if I have issues, I'll post back.
     

Share This Page