(2009-08-22, 08:32 PM)MattRogowski Wrote: [ -> ]UPDATE `mybb_users` SET `additionalgroups` = 'X' WHERE `usergroup` = 'Y';
This will put users in usergroup Y into additional group X; change the X and Y to the relevant usergroup IDs.
This would work but it seems to migration only transferred over the primary groups, in which ALL registered members are in
Not all hope is lost however, I've figured out what I need to do, which still requires me to update 1 by 1, but at least it's still easier than doing it through the users' profiles in the ACP.
UPDATE `mybb_users` SET `additionalgroups` = 2 WHERE `username` = '[username]';
UPDATE `mybb_users` SET `usergroup` = 9 WHERE `username` = '[username]';
UPDATE `mybb_users` SET `displaygroup` = 9 WHERE `username` = '[username]';
I have a LOT of secondary group assignments to do however, so I'm working on a php script that will make the process easier.
edit: I should note that I was slightly backwards in my approach, which can be seen above. I've decided it was better to update the primary group with the new group I want selected members in, and update the additional groups to the standard 'registered' group. And then update the display group accordingly
Here's what I came up with. It does what I want, prints the results, and makes me happy
Just a few notes:
1. Please do not use this script if you don't know what it does, or do not know how to manipulate MySQL or PHP.
2. This script will only work if you have the info needed. I got the user list that I wanted to change groups for from a printout of the phpbb3 user groups.
2a.Group IDs can be obtained through a MySQL tool like phpMyAdmin.
(MyBB Group IDs, not your old installation!! Which means the groups MUST already exist in your MyBB install)
3. Use at your own risk. I make no guarantees that this script will work for you.
4. If you have a question, or don't know how something in this script works, then ASK first!!!
5. If you did not heed the above and break your mybb install, please do not blame me.
<html>
<head><title>Updating User Groups</title></head>
<body>
<?php
// DB connect info
$dbhost ='host';
$dbuser ='uname';
$dbpass ='pass';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
// select our DB
$dbname ='database';
mysql_select_db($dbname);
// create array of users for updating primary group '8'
$gid8 = array('user1','user2','user3','user4','user5','user6');
// create array of users for updating primary group '9'
$gid9 = array('user11','user21','user31','user41','user51','user61');
// update fields for each user whose groups are being changed (identified by gid)
foreach ($gid8 as $value)
{
// we want the users in this array to have their primary group changed to 8
$result = mysql_query("UPDATE mybb_users SET usergroup = '8' WHERE username = '".$value."'") or die(mysql_error());
// we want them to remain members of group 2 as well as group 9, so we update that here
$result = mysql_query("UPDATE mybb_users SET additionalgroups = '2,9' WHERE username = '".$value."'") or die(mysql_error());
// we want their display group to be changed to 8 as well, so we update that here
$result = mysql_query("UPDATE mybb_users SET displaygroup = '8' WHERE username = '".$value."'") or die(mysql_error());
}
foreach ($gid9 as $value)
{
// we want the users in this array to have their primary group changed to 9
$result = mysql_query("UPDATE mybb_users SET usergroup = '9' WHERE username = '".$value."'") or die(mysql_error());
// we want them to remain members of group 2, so we update that here
$result = mysql_query("UPDATE mybb_users SET additionalgroups = '2' WHERE username = '".$value."'") or die(mysql_error());
// we want their display group to be changed to 9 as well, so we update that here
$result = mysql_query("UPDATE mybb_users SET displaygroup = '9' WHERE username = '".$value."'") or die(mysql_error());
}
// Get our results
$result = mysql_query("SELECT * FROM `mybb_users` WHERE `usergroup` = '8' OR `usergroup` = '9'") or die(mysql_error());
$num_rows = mysql_num_rows($result);
echo "There are ".$num_rows." records displayed...";
print "<table width=500 border=1>";
print "<tr><td>Username</td><td>Primary Group</td><td>Secondary Group(s)</td><td>Display Group</td></tr>";
//Print the results
while ($row = mysql_fetch_array($result)){
print "<tr>\n";
print "<td>".$row['username']."</td>\n";
print "<td>".$row['usergroup']."</td>\n";
print "<td>".$row['additionalgroups']."</td>\n";
print "<td>".$row['displaygroup']."</td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($conn);
?>
</body>
</html>