MyBB Community Forums

Full Version: Check if a user is in the banned usergroup or not
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.
I am trying to add a couple of things to the postbit so that if the user who has posted is banned they have a different avatar and an unban button under them. Are there any ways I can check if a user is in the banend user group (in this case number 7)? If possible without making a database query?
Thanks, for the help.
Why would you allow you "banned" users to post anyway ?
So they can post in an area to tell us why they should be unbanned. That's not the point though. I want something so when anybody looks at a banned users postbit it displays something.
if ($mybb->user['usergroup'] == 7)
{
//do something here
}
Just create a forum and make it so only banned users and staff can see it. Make it so users can read only own threads.
Since nobody in this thread has ANY IDEA WHAT IM TALKING ABOUT me and my friend just decided to do a database query
<?php 
$user = $post['uid'];
$query = $db->simple_select("users", "usergroup", "uid='$user'");
$result = $db->fetch_array($query);
$group =  implode("",$result);
if($mybb->usergroup['canmodcp'] == 1 && $group == 7) {
echo " &nbsp;&nbsp; <a href=\"modcp.php?action=liftban&uid={$post['uid']}&my_post_key={$mybb->post_code}\" /><img src=\"images/1/icons/unban.png\" title=\"unban this user\" /></a>";
} ?>
You don't have to use a database query. Are you creating your own custom plugin, custom code or using PHP in Templates?
if($mybb->usergroup['canmodcp'] == 1 && $post['usergroup'] == 7)
{
    $post['avatar'] = "new avatar here";
    $post['unban_button'] = " &nbsp;&nbsp; <a href=\"modcp.php?action=liftban&uid={$post['uid']}&my_post_key={$mybb->post_code}\" /><img src=\"images/1/icons/unban.png\" title=\"unban this user\" /></a>";
}

...

Then put $post['unban_button'] where you want it in the templates.

Otherwise you'll have to run that query for every post... 20 posts per page, 20 queries...