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

XF 1.3 SQL for moving primary to sec usergroups


Well-known member
I imported my usergroups from vB and now I want to adapt the usergroups to the xF permission system. Therefor I would like to copy the primary user group ID to the secondary_group_ids field and replace the primary user group ID with 2/default. The problem is not to lose the existing secondary Ids. Is this possible with SQL?
1. query: UPDATE xf_user SET secondary_group_ids = 11 WHERE user_group_id = 11;
2. query: UPDATE xf_user SET user_group_id = 2 WHERE user_group_id = 11;
would overwrite existing secondary group IDs right?
thank you - all the best,


Well-known member
I just found out that the secondary_group_ids are also stored in the table xf_user_group_relation. So this is more complex than I thought. I think I`ll have to ask a programmer to write a tool for it as this concerns a large number of users. It would have been better to change the groups and permissions already in vB before the import but I can`t go back now.

Jake Bunce

XenForo moderator
Staff member
xf_user_group_relation can be rebuilt by simply rebuilding the user cache:

Admin CP -> Tools -> Rebuild Caches

You only need to update those two columns in xf_user and then rebuild the cache. But the query isn't simple because secondary_group_ids is a comma list.

There is no reason to use direct queries though. This feature can handle the change of groups:

Admin CP -> Users -> Batch Update Users