Our site has subsystems besides Xenforo. When people signup for our site, they signup using our proprietary security system that controls access to all the subsystems, including Xenforo. That system adds people to XenForo, using an outdated addon called XenForoSDK. It does not add people to different user groups. It just adds them and people are put into a default group using group promotions.
We need to be able to add people to various forum user groups when they signup for our site. The group assignments vary by which products they buy. Access to our forums is part of what they are paying for. Currently, we have a person login to the Xenforo Admin Control Panel, search for the new users based on data printed out by our security system, then check the little boxes to put them into a forum user group. It's impractical.
The requirement is to have a program that runs as part of our proprietary site signup that puts people into the right forum groups based on what they have bought.
To test a process for automating this task, I created a file called addUserScottyJakes_to_Group_38.php. The file is in the xenforo directory with the same ownership and permissions as index.php and admin.php. This is 100% of the file's contents:
<?php $startTime = microtime(true); $fileDir = dirname(__FILE__); require($fileDir . '/library/XenForo/Autoloader.php'); XenForo_Autoloader::getInstance()->setupAutoloader($fileDir . '/library'); XenForo_Application::initialize($fileDir . '/library', $fileDir); XenForo_Application::set('page_start_time', $startTime); $dependencies = new XenForo_Dependencies_Public(); $dependencies->preLoadData(); $name = 'Scotty Jakes'; $userModel = XenForo_Model::create('XenForo_Model_User'); $user = $userModel->getUserByName($name); $user_id=$user->getUserId(); $userModel = XenForo_Model::create('XenForo_Model_User'); $userModel->removeUserGroupChange($user_id, 'RANDOM_STRING'); $userModel->addUserGroupChange($user_id, 'RANDOM_STRING', 38);
How can I make this work?