There we go, I went ahead and wrote a Scheduled Task that every 10 minutes would check for anybody in the primary group 'Registered users' with the custom profile field9 set to 'Yes' and move them to usergroup 9, and vice versa. Sorry in advance for unclean code and please don't hate.
Place the code in the box below in a .php script in your /includes/cron folder and create a new scheduled task pointing to that script.
Replace 'field9' with the field you want to check. Replace 'Yes' and 'No' with the values of your field9 option.
Replace 'New member' and 'Introductory grower/distributor' with your chosen user titles.
Replace the usergroup numbers 2(Registered member) and 9(Custom usergroup) on the MySQL queries with the numbers of the usergroups you want to migrate to and from.
Sorry I can't go into more detail, sort of in a hurry to get this job done for my client. I don't recommend attempting this if you are not comfortable editing SQL queries.
Be sure to test this out on your forums using the 'Run now' option from the Scheduled Tasks section of the control panel, if you have messed up the syntax at all the control panel should return an error and send a copy of the error to the board owner via email.
I recommend backing up your databases before trying this out just in case you do something wrong, I don't hold any responsibility for lost or corrupt data in your database.
P.S. I recommend putting a notice in your custom usergroup description letting the user know that it can take up to 10 minutes for the changes to take effect to avoid confusion. (Or whatever interval you set your scheduled task job to.)
PHP Code:
<?php
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}
$tmpA = $vbulletin->db->query_read("
SELECT user.userid,user.usergroupid,user.username
FROM `user`,`userfield` AS field
WHERE user.usergroupid = 2
AND user.userid=field.userid
AND field.field9='Yes'
");
while ($tmpU = $vbulletin->db->fetch_array($tmpA))
{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET usergroupid = 9, usertitle='Introductory grower/distributer'
WHERE userid = " . $tmpU['userid']);
}
$tmpA = $vbulletin->db->query_read("
SELECT user.userid,user.usergroupid,user.username
FROM `user`,`userfield` AS field
WHERE user.usergroupid = 9
AND user.userid=field.userid
AND field.field9='No'
");
while ($tmpU = $vbulletin->db->fetch_array($tmpA))
{
$vbulletin->db->query_write("
UPDATE " . TABLE_PREFIX . "user
SET usergroupid = 2, usertitle='New member'
WHERE userid = " . $tmpU['userid']);
}
?>