1. 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

Discussion in 'XenForo Questions and Support' started by sinucello, May 6, 2014.

  1. sinucello

    sinucello 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,
  2. sinucello

    sinucello 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.
  3. Jake Bunce

    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
    jeffwidman and sinucello like this.
  4. sinucello

    sinucello Well-Known Member

    wow. You are a star and just saved me a lot of time and/or money. I love xenForo. Thank you so much!!

Share This Page