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

XF 1.5 SQL Help - Adding Secondary Groups, and Upgrades

Discussion in 'XenForo Questions and Support' started by Michael Murguia, Jul 17, 2016.

  1. Michael Murguia

    Michael Murguia Active Member

    Hi All! First, thank you in advance for your help! Below, the specific question is highlighted in blue!

    I think I am about half way through this project, and would love some help completing the task.

    Part 1
    Adding a secondary group via SQL using an email list works fine like this:

    Code:
    UPDATE xf_user SET  secondary_group_ids =  '6' WHERE email IN ('email1@gmail','email2@gmail');
    Unintended behavior 1: This also removes preexisting secondary groups for the list of users. Can this be prevented? I only want to add, not remove groups.

    Unintended behavior 2: Once secondary groups are set using this method, adding an upgrade package which adds these users to a secondary group no longer works. When upgraded, they are not added to the secondary group associated with the upgrade.

    Part 2
    At the same time, I would like to add an upgrade package for the list of users. I imagine the SQL would be similar to Part 1, but I don't know the proper syntax. I think I would need to know the term for the upgrade package equivalent of "secondary_group_ids". Again, its important no other upgrades are removed.
     
  2. Mike

    Mike XenForo Developer Staff Member

    You absolutely can't add users to groups like this. If you're going to do it, you must do it through the same approach and APIs that XenForo uses (via PHP). Attempting to modify the database like this WILL cause problems and break things. There is a lot more to modifying user groups than just modifying this one area.
     
  3. Michael Murguia

    Michael Murguia Active Member

    Ah! I was doing this on someone else's advice. Good to know! So, given these needs, do you have a recommendation? I have about 1,000 users to check and update. What would be the best way to do it?

    Thanks!

    M
     
    Last edited: Jul 17, 2016
  4. Mike

    Mike XenForo Developer Staff Member

    Unless you're comfortable writing custom PHP code to modify these users and interact with XF's API, I'm afraid adding them via the control panel may be what needs to be done.

    If you want to go down the root of a user upgrade for these users, you need to do that instead of the direct group manipulation. This ensures that the group membership is connected to them having the upgrade active (so if the upgrade expires, the group is removed).
     
  5. Michael Murguia

    Michael Murguia Active Member

    OK, thank you. I'd be interested in hiring for plugin development to do this if anyone is interested. Does this site refer developers?

    Thanks again!

    M
     
  6. Mike

    Mike XenForo Developer Staff Member

  7. Michael Murguia

    Michael Murguia Active Member

    Great! Thank you!
     

Share This Page