Database Query to Add List Usernames to a Secondary Usergroup

danielTMC

Member
Does anyone know a database query that can be used to assign a list of usernames to a given secondary usergroup.

Many thanks in advance.
 
Here's what I did, which worked great for me. You can learn a lot about my personality from this script...

First, I got a list of all current staff and I saved the results to Excel.
select *
from xenforo.xf_user u
where is_staff = true

Then, I made everyone no longer a staff member:
update xenforo.xf_user u
set is_staff = false
where is_staff = true

Then, I made everybody a staff member that I wanted to change:
update xenforo.xf_user u
set is_staff = true
where username in
(
-- usernames go here
)

Then I used the "Batch update users" feature in the admin console to update anyone who was temporarily marked as a staff member. There are lots of things you can change with this feature, including what secondary groups users are in.

Then, I made everyone no longer a staff member again:
update xenforo.xf_user u
set is_staff = false
where is_staff = true

Then, I reverted back the actual staff members:
update xenforo.xf_user u
set is_staff = true
where username in
(
-- usernames go here
)
 
Back
Top Bottom