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

What is permission_combination_id?

Discussion in 'XenForo Development Discussions' started by chickenputty, Apr 17, 2016.

  1. chickenputty

    chickenputty Member

    I'm working on an external script to sync user's ranks from Minecraft to their XenForo account. I've set their secondary_group_ids and display_style_group_id with a MySQL query, but the permission_combination_id is definitely concerning.

    How do I calculate the permission_combination_id? or is there a way to force XenForo to calculate it?
  2. Jeremy P

    Jeremy P Well-Known Member

    If you can, I'd highly recommend using the XF framework to make these sorts of changes instead of interfacing with MySQL directly. Updating things via DataWriters should make sure the changes cascade and everything else gets updated accordingly.
  3. chickenputty

    chickenputty Member

    How do you suggest I begin to learn more about this?
  4. Jeremy P

    Jeremy P Well-Known Member

    The developer documentation is lacking, so the only good suggestion I can make isn't a satisfying one... read through existing code. Try to find a place in the core that's doing what you need to do, and see how it does it. For this case, I'd recommend XenForo_ControllerAdmin_User::actionSave().

    You will need to bootstrap the XF framework in your custom script:

    $fileDir dirname(__FILE__); // may need to adjust this to point to XF root

    require($fileDir '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader($fileDir '/library');

    XenForo_Application::initialize($fileDir '/library'$fileDir);
    From there you can use objects and methods from XF. I've taken some of the following from the method I named above. To get the existing secondary group IDs, you might need to first query the user using XenForo_Model_User.
    $writer XenForo_DataWriter::create('XenForo_DataWriter_User');

    $writer->setSecondaryGroups($secondaryGroupIds); // this needs to contain any existing secondary group ids too

    chickenputty likes this.

Share This Page