[Request]Auto Usergroup Change
#31
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???
Reply
#32
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'
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Reply
#33
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..
Reply
#34
Where did you insert the code? It should be at the end of the file global.php.
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Reply
#35
Yes I inserted the code at the end of global.php before ?>
Reply
#36
help.. it's either not automatically updating or automatically updating my user that reached the requirement into Unregistered (group 0)
Reply
#37
Please attach your global.php here.
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Reply
#38

.php   global.php (Size: 10.99 KB / Downloads: 242)
Reply
#39
Try the attached file. I replaced $gid17 with $gid1 as there's no need to change the variables.


Attached Files
.php   global.php (Size: 10.99 KB / Downloads: 219)
Greets,
Michael
-------------
[Image: donation_drive_sig.png]
Reply
#40
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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)