He is right..I found the problem.
Inside /admin/modules/forum/management.php (deletemod action)
$db->delete_query("moderators", "mid='{$mid}'");
$query = $db->simple_select("moderators", "*", "uid='{$mod['uid']}'");
if($db->num_rows($query) == 0)
{
$updatequery = array(
"usergroup" => "2"
);
$db->update_query("users", $updatequery, "uid='{$mod['uid']}' AND usergroup != '4' AND usergroup != '3'");
}
As you can see if the user is not in group 3 or 4 it reverts them to 2. There might be a group they were in besides 2. Mybb doesn't have to track it and imho shouldn't alter it when adding a forum moderator.
Here is what I think is the add function same file.
elseif($mybb->input['add'] == "moderators")
{
$forum = get_forum($fid);
if(!$forum)
{
flash_message($lang->error_invalid_forum, 'error');
admin_redirect("index.php?module=forum/management&fid={$fid}#tab_moderators");
}
$query = $db->simple_select("users", "uid, username", "username='".$db->escape_string($mybb->input['username'])."'", array('limit' => 1));
$user = $db->fetch_array($query);
if($user['uid'])
{
$query = $db->simple_select("moderators", "uid", "uid='".$user['uid']."' AND fid='".$fid."'", array('limit' => 1));
$mod = $db->fetch_array($query);
if(!$mod['uid'])
{
$new_mod = array(
"fid" => $fid,
"uid" => $user['uid'],
"caneditposts" => 1,
"candeleteposts" => 1,
"canviewips" => 1,
"canopenclosethreads" => 1,
"canmanagethreads" => 1,
"canmovetononmodforum" => 1
);
$mid = $db->insert_query("moderators", $new_mod);
$db->update_query("users", array('usergroup' => 6), "uid='{$user['uid']}' AND usergroup='2'");
$cache->update_moderators();
$plugins->run_hooks("admin_forum_management_start_moderators_commit");
// Log admin action
log_admin_action('addmod', $new_mod['fid'], $user['username'], $fid, $forum['name']);
flash_message($lang->success_moderator_added, 'success');
admin_redirect("index.php?module=forum/management&action=editmod&mid={$mid}");
}
else
{
flash_message($lang->error_moderator_already_added, 'error');
admin_redirect("index.php?module=forum/management&fid={$fid}#tab_moderators");
}
}
else
{
flash_message($lang->error_moderator_not_found, 'error');
admin_redirect("index.php?module=forum/management&fid={$fid}#tab_moderators");
}
Does the moderator group have to be main? Why can't it be an additional usergroup? Personally I have come across this same problem and why I have not assigned individual forum moderators at HF. I am not liking the way Mybb handles it. Since it's only a forum moderator the group should imho be an additional usergroup.
Example of problem.
Member as VIP membership (usergroup 8)
Member is assigned to moderate forum X
Member is now in group 6 as main group when he should be in 8
Member looses all group 8 privileges
Member is eventually removed from forum moderator
Member is now group 2
I hope this clarifies some of the problems with the way it's handled. A few alterations to this one file should fix it. I am assuming all the checks for someone being a forum moderator are based off both usergroup and displaygroup columns. Someone from dev team can hopefully double check that.
The way it's setup now is poor. It's why I don't have any forum moderators on HF yet I need them. Problem is I set someone as a forum moderator and then they can't have the assigned VIP privileges.
Please advise.
EDIT: I have reviewed is_moderator function and apparently it doesn't care about usergroup and read the cache of the moderators table. I don't see where a usergroup is even needed to be group 6. So I believe a good fix is to just assign it an additional usergroup (check it make sure they are not already additional 6) and upon removal just take it out of additionalgroups. I don't see a need to make this the main usergroup.
EDIT 2: On my test forums I have taken a test member and placed them in usergroup 8 with additionalgroup 6 and a moderator on one forum. All the moderator functions appear normal. As a matter of if remove the additionalgroup 6 the moderarator powers still work just fine since the basis of forum moderator is off the table mybb_moderators. This can and should be fixed to be more logical and allow greater control. The need to check for groups 3 or 4 won't even be neccessary under this change. Just make sure they are already not in additionalgroup 6.
Thank you.