MyBB Community Forums

Full Version: My first Plugin: Help!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My first plugin. I would like to implement the following inside a plugin:

Michael83 Wrote:A nicer solution (far less queries): Insert into global.php
## Update Usergroup ##
// Usergroup-ID Group 1 (old group)
$gid1 = "2";

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

// 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 = '".$gid2."', displaygroup = '".$gid2."' WHERE uid = '".$mybb->user['uid']."' AND usergroup = '".$gid1."'");
}
## Update Usergroup ##
When you use this method, you have to run the following query via phpmyadmin to update all users that already have more than x posts:
UPDATE mybb_users SET usergroup = 'x', displaygroup = 'x' WHERE postnum >= 'y' AND usergroup = 'z'
x = new goup id
y = minimal post number
z = old group id


I would also like to make it so in the options when you set a certain number of posts to change from usergroup, you can chose what group to change to, and what group they must be in for this change to take affect. Also, I would like to be able to automatically switch current users to this group using a checkbox.

So example:
Add new Changer: http://www.louhabs.com/mybbmods/usergrou.../index.htm
Manage Current Changers: http://www.louhabs.com/mybbmods/usergrou...groups.htm

[Manage Changers is just so you know what I want there. There is no example]

Anyone willing to help me make this?