![]() |
SQL query to delete secondary usergroup
Due to some recent changes in usergroups, some members inadvertently ended up with their PRIMARY and SECONDARY usergroups being duplicated.
This is causing issues when these members request for a new password and the systems throws them into a loop where they are unable to get their primary usergroup changed from Email Verification back to their normal usergroup as the system already has them tagged to the secondary usergroup. Anyway, i am looking for a SQL query to manually delete the secondary usergroup of the affected members (about 10K of our 130K members) which will be too much to do manually. Thanks! |
Anyone? Help? Please??
|
I don't know how to do it in SQL, but you could use this script:
PHP Code:
Next, create a new php file (like maybe removegroup.php) and put in the above code. Then change this line PHP Code:
to change X to the group id your want to remove. Then run the script (go to it with your browser). When you're done you'll probably want to remove it. BTW, this code comes from admincp/usergroup.php where it's used to remove users from a group when the group is being deleted. |
I was just about to start a script to do this but kh99 beat me to it.
One thing I would suggest is place that entire script inside a conditional so it runs for the admin only and then it can be a plugin in showthread start PHP Code:
|
Quote:
|
Thanks for the replies - not exactly what I was looking for and will have to discuss with the other SysAdmin who is a little more well-versed than I am with MySQL.
|
I have not tested this but you can try:
Code:
UPDATE user SET membergroupids = REPLACE(membergroupids,'2',''); Update all users, set their member group id (secondary usergroup) to "Blank" or '' where it currently is 2 i.e. Registered User/Member. Now go through and do this for all the secondary usergroups listed in the usergroup manager so if you have a custom usergroup none of us have lets call it Main VIP which is usergroupid #29 you simply use this now: Code:
UPDATE user SET membergroupids = REPLACE(membergroupids,'29',''); Edit: Ahh I had to install a staging site on my localhost tonight regardless so tested and it works ;). |
I'm not clear on something: Is "Email Verification" a custom usergroup or do you mean "Users Awaiting Email Confirmation" (group 3)? Are several usergroups duplicated in secondary usergroups?
|
Quote:
Also, I believe he only wanted to remove on secondary user group, where it duplicates the primary group. |
Quote:
|
All times are GMT. The time now is 02:19 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|