Looking at your core code, I think I may have found what I’m looking for:
Would that work?
Yes, you are basically correct. This implementation is unfortunately very old and a bit tricky, so you have to be aware of something:
- In the first parameter you pass the ID of the user
- In the second parameter you have to pass an array of usergroup IDs of which the user should be a member of
Take into account, that this has to be the full list. So for example if the user currently belongs to group 1,2,3 and you now pass 4 to it, the user will not belong to 1,2,3 anymore. Instead, you have to pass 1,2,3,4 to it.
Confusing, I know, and I should rewrite that one day.