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

Query to remove everyone from a secondary usergroup?

Discussion in 'XenForo Questions and Support' started by CyclingTribe, Jun 26, 2012.

  1. CyclingTribe

    CyclingTribe Well-Known Member

    I searched but couldn't find a query to use that would allow me to remove everyone from a secondary usergroup; in my case, group ID: 13

    Anyone able to advise on how best to do this as I have 2,000 members that need removing from this group and doing it by hand is just a total no-no ... ;)

    Shaun :D
  2. Nasr

    Nasr Well-Known Member

    Delete the group and recreate it?
    Yorick likes this.
  3. Chris D

    Chris D XenForo Developer Staff Member

    That is going to be easier.

    It's tricky as you have to consider that your secondary_user_groups column for some people may look like:


    But for some people it may look like:

    2, 13, 3, 4

    Others it may look like

    2, 13

    (sometimes on its own, sometimes with others and with a comma and other times with others and without a comma).
  4. CyclingTribe

    CyclingTribe Well-Known Member

    Quick and dirty, but it will also change the group ID and I have lots of things tied to the ID - which is why I was looking for a query.

    I'd previously automatically opted everyone into this group but now what to reverse it and opt everyone out and only those who specifically request it, opt them back in.

    I suppose I could run a series of replace queries for "13" - ", 13," - "13, " - ", 13" - that should cover it shouldn't it?
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    What Yorick said. A query is not suitable for this. You really need a custom PHP script to process the list.
    Yorick likes this.
  6. CyclingTribe

    CyclingTribe Well-Known Member

    Okay, thanks guys - I can't really write a script so I'll do it manually. <Nips off to suggest bulk removal from secondary groups!> (y)

    Shaun :D
  7. CyclingTribe

    CyclingTribe Well-Known Member

    1100 done - only 900 more to go ... :coffee:

    Oh, and please like this post if you'd like to see an option for bulk removal from secondary groups!
  8. Chris D

    Chris D XenForo Developer Staff Member

    What if you deleted the group (thus removing everyone from it) then recreated the group, but then change its new ID to 13?

    Let me test that for you.

    EDIT: Seems to work in my testing...
    tekgirl and CyclingTribe like this.
  9. CyclingTribe

    CyclingTribe Well-Known Member

    Perfect - thanks - worked a treat. :D

Share This Page