MyBB Community Forums

Full Version: How can i put "admin-mod-user" text on the whosonline ??
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Since I wanted this list in multiple places (Who's Online block on the index page, Member List, etc), I made a function. $open get prepended to every formatted name, while $close gets appended. The string {gid} will be translated to the actual group id, so you could include URLs (for example, link to a modified memberlist.php which only lists users who belong to a certain group).

function formattedgrouparray( $open="", $close="")
{
  global $db, $mybb, $settings, $lang;
  $query = $db->query("SELECT * FROM " . TABLE_PREFIX . "usergroups WHERE gid!=1 ORDER BY isbannedgroup ASC, showforumteam DESC, issupermod DESC, usertitle");
  $groups = array();
  while ( $group = $db->fetch_array($query) )
  {
    $my_open = str_replace( array("{gid}"), array($group['gid']), $open);
    $my_close = str_replace( array("{gid}"), array($group['gid']), $close);
    $title = ($group['usertitle']) ? $group['usertitle'] : $group['title'];
    $groups[] = $my_open . formatname( $title, $group['gid'] ) . $my_close;
  }
  return $groups;
}

You include the following code on each page you want the legend to show up (not: I should allow the word Legend to be translated):

$groups = formattedgrouparray();
$groups_legend = "<b>Legend</b>: " . join(" &nbsp;|&nbsp; ", $groups);

Then I added the variable $groups_legend to the template.
Man thnks a lot...