MyBB Community Forums

Full Version: [Request]Auto Usergroup Change
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5
Here's the code I inserted:

## Update Usergroup ##
// Usergroup-ID Group 1 (old group)
$gid1 = "2";

// Usergroup-ID Group 2 (new group)
$gid2 = "17";

// Minimal number of posts
$minposts = "5";

// Update user
if ($mybb->user['postnum'] == $minposts)
{
// Update usergroup
$update_group = $db->query("UPDATE ".TABLE_PREFIX."users SET usergroup = '".$gid17."', displaygroup = '".$gid17."' WHERE uid = '".$mybb->user['uid']."' AND usergroup = '".$gid2."'");
}
## Update Usergroup ##

Where 17 is the id of the new usergroup. It's not automatically updating the usergroup (not running the query). Did I forget anything or whatsoever?

BTW, The first method is CORRUPTING my new usegroup. WTH???
Did you run the query? According to your code it should be:
UPDATE mybb_users SET usergroup = '17', displaygroup = '17' WHERE postnum >= '5' AND usergroup = '2'
Yes I ran the query. The query is functioning well, my problem is that the script in global.php is not automatically updating the user group when user reaches the post requirement. I don't know why..
Where did you insert the code? It should be at the end of the file global.php.
Yes I inserted the code at the end of global.php before ?>
help.. it's either not automatically updating or automatically updating my user that reached the requirement into Unregistered (group 0)
Please attach your global.php here.
Try the attached file. I replaced $gid17 with $gid1 as there's no need to change the variables.
I replaced the global.php. It's not mysteriously resetting the usergroup to 0 now, but it is still not automatically updating the usergroup. (From 2 to 17 when postnum = 1)
Pages: 1 2 3 4 5