PDA

View Full Version : Bulk change of User Group based on User Profile fields


cb1100r
12-04-2012, 11:47 AM
Can anyone suggest a way of changing the User Group for groups of current users based on data in custom User Profile Fields.

For example, I have international users from different countries, and their country of residence is show in a custom User Profile Field.

If I want to change the Primary User Group for all the users in say "Japan" is this possible without having to do each user separately... for a large group with would clearly be almost impossible.:eek:

Any help or tips would be greatly appreciated.


Steve

kh99
12-04-2012, 12:58 PM
You can change the usegroup using a query, like:
UPDATE user SET usergroupid=X WHERE fieldY='Japan'


where of course X is the id of the new group for Japan users, and Y is the id of your custom profile field. But I think if you do it that way, it's possible that not everything gets updated as it should when a usergroup is changed. What you might do is make a "temporary Japanese" usergroup, use the above query to move all "Japan" users to the temporary group, then use "Move/Prune Users" to move then from the temporary group to the Japan group.

cb1100r
12-04-2012, 01:50 PM
Thanks kh99

I guess you run the query from the Maintenance section. But were's the switch to allow running of queries. I seem to have that turned off for administrators on my board.

kh99
12-04-2012, 02:01 PM
You can use the Maintenance section or use phpMyAdmin if you have that available.

There's a variable in the config.php where you have to add the userid of users allowed to do queries.

I feel like I should add that you should be very careful, and probably you should have a backup before you start changing things.

cb1100r
12-05-2012, 03:52 PM
Thanks again.

Got that... I think phpMyAdmin is best... I can see what I'm doing a lot clearer!

and I can see how easily it can be to stuff things up.. so I'll take the Backup advice!~

Cheers