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

Permissions

Discussion in 'XenForo Development Discussions' started by ManagerJosh, May 15, 2015.

  1. ManagerJosh

    ManagerJosh Well-Known Member

    Is there developer documentation or tutorials that explains how to leverage the existing permission system inside XF and build upon it in order to create/add/manage permissions for a potential addon?
     
  2. Jake B.

    Jake B. Well-Known Member

    Just use the interface for creating new permissions, and use something along the lines of:

    Code:
    $visitor = XenForo_Visitor::getInstance();
    if ($visitor->hasPermission('permission_group_id', 'permission_id')
    {
        // Do something if they have permission
    }
    
    That will work in most cases, otherwise you'll want to use
    Code:
    $userModel = $this->getModelFromCache('XenForo_Model_User');
    $user = $userModel->getUserById($userId);
    $user['permission'] = @unserialize($user['global_permission_cache']);
    if (XenForo_Permission::hasPermission($user['permissions'], 'permission_group_id', 'permission_id'))
    {
        // Do something if they have permission
    }
    
     
  3. ManagerJosh

    ManagerJosh Well-Known Member

    What about adding our own category and permission sets inside the permission area in the AdminCP?
     
  4. Jake B.

    Jake B. Well-Known Member

    What do you mean exactly?
     

Share This Page