Query to remove everyone from a secondary usergroup?

CTXMedia

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 ... ;)

Thanks,
Shaun :D
 
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:

13

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).
 
Delete the group and recreate it?

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?
 
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...
Hey @Chris D - I have a situation where I need to do this in 2.2, as I screwed up on my user group promotions and need to remove everyone from a particular group. Would this still work? I've exported this particular group from the user_group table via phpmyadmin, in order to save all of the permissions associated with it. I was planning to delete it in ACP next, then restore it via an INSERT query in phpmyadmin using that exported row. Would that effectively remove everyone from the group so that I can run a promotion and re-add the appropriate users back to it? Should I rebuild the user cache and user group promotion cache before re-adding the group?
 
What are you trying to do exactly? Since my old post we’ve added batch update users which can be used to remove users from a user group.
 
What are you trying to do exactly? Since my old post we’ve added batch update users which can be used to remove users from a user group.
Forgot about the batch user update Chris. I'm trying to remove all members from a few particular usergroups that I have tied to user group promotions, so I can start over with the promotions. I know with those promotions, once they are in the group, you can't remove them from the usergroups. I'll use the batch user update for this. Thanks for the reminder.
 
What are you trying to do exactly? Since my old post we’ve added batch update users which can be used to remove users from a user group.
Hi @Chris D - I used the Batch User Update and now I can't get a promotion to work afterwards:
 
Top Bottom