I'm looking to add a secondary usergroup to a xenforo user from my site's code.
I've figured out how to get user details and check if the user already has the usergroup
I see in XF there is a removeUserFromGroup($groupId) function
I was hoping there was a $user->addUserToGroup($groupId) function, but I can't find it
Thanks
I've figured out how to get user details and check if the user already has the usergroup
Code:
$dir = "/path";
require($dir . '/src/XF.php');
XF::start($dir);
$userid = 1;
$site_usergroup = 14; // this usergroup is created in Xenforo
$user = \XF::em()->find('XF:User', $userid);
if ($user->isMemberOf($site_usergroup) == FALSE)
{
# add usergroupid to user
}
I was hoping there was a $user->addUserToGroup($groupId) function, but I can't find it
Thanks