The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
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! |
#2
|
|||
|
|||
Anyone? Help? Please??
|
#3
|
|||
|
|||
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. |
#4
|
|||
|
|||
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:
|
Благодарность от: | ||
kh99 |
#5
|
|||
|
|||
lol...it seems to happen a lot, either no one's doing it or two of us are. Anyway, I used to use hook misc_start for these things and pick a value for "do", but then someone pointed out that you really only need to include global.php, so that seemed easy enough. But that's a good point, if someone prefers to do it via plugin, that has it's advantages.
|
#6
|
|||
|
|||
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.
|
#7
|
||||
|
||||
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 . |
#8
|
|||
|
|||
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?
|
#9
|
|||
|
|||
Good job - I thought about ways to do it but couldn't come up with any. Since that text field can be a comma-separated list if the user belongs to more than one secondary group, I was thinking of handling a possible comma. But the code that reads and explodes that field is pretty forgiving [S]so I think your solution works.[/S]. I changed my mind...see the later posts.
Also, I believe he only wanted to remove on secondary user group, where it duplicates the primary group. |
#10
|
|||
|
|||
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|