Log in

View Full Version : Color coded usergroups


Clydesdale
01-25-2012, 02:33 PM
Good morning to you all.

I am wanting to know how i would add a color code section to the Currently Active Users: 2 (1 members and 1 guests) section.

Something similar to either

• Administrators • Super Moderators • Moderators • VIP Member • Registered Users

or

Administrators | Moderators | Punished Member | Super Moderators | VIP Member

But with each group a different color.

I am running 3.8.7

Thanks in advance for the help

kh99
01-25-2012, 03:50 PM
$vbulletin->usergroupcache[] has the information for each group, so in a plugin you could do something like:


foreach ($vbulletin->usergroupcache AS $usergroup)
{
$usergroups[] = $usergroup['opentag'] . $usergroup['title'] . $usergroup['closetag'];
}
$usergroup_legend = implode(' | ', $usergroups);


or if you want to control the groups or order of the included groups, you could use this instead:

foreach (array(6, 5, 4, 3, 2, 8) AS $groupid)
{
$usergroup &= $vbulletin->usergroupcache[$groupid];
$usergroups[] = $usergroup['opentag'] . $usergroup['title'] . $usergroup['closetag'];
}
$usergroup_legend = implode(' | ', $usergroups);


(BTW, I haven't tried these so there could be typos...).

Clydesdale
01-25-2012, 04:36 PM
$vbulletin->usergroupcache[] has the information for each group, so in a plugin you could do something like:


foreach ($vbulletin->usergroupcache AS $usergroup)
{
$usergroups[] = $usergroup['opentag'] . $usergroup['title'] . $usergroup['closetag'];
}
$usergroup_legend = implode(' | ', $usergroups);


or if you want to control the groups or order of the included groups, you could use this instead:

foreach (array(6, 5, 4, 3, 2, 8) AS $groupid)
{
$usergroup &= $vbulletin->usergroupcache[$groupid];
$usergroups[] = $usergroup['opentag'] . $usergroup['title'] . $usergroup['closetag'];
}
$usergroup_legend = implode(' | ', $usergroups);


(BTW, I haven't tried these so there could be typos...).

:confused: At the risk of sounding like an idiot....

I am a extreme novice at all of this. can you break this down "barney style?"

kh99
01-25-2012, 05:27 PM
Well, a couple of things: the code I posted would only build the legend part, and it only works if you've already entered html markup in the usergroup manager to color code usernames by group. But assuming you've done that, create a new plugin using hook location forumhome_complete and this code:

foreach ($vbulletin->usergroupcache AS $usergroup)
{
$usergroups[] = $usergroup['opentag'] . $usergroup['title'] . $usergroup['closetag'];
}
$usergroup_legend = implode(' | ', $usergroups);


Then in your FORUMHOME template, put $usergroup_legend where you want it to appear. When I tried it it came out fairly large, so you might want to put a <span>..</span> around it or something to control the font size.

HMBeaty
01-25-2012, 07:36 PM
Or you could look in the usergroups settings at the top for the html markup. ;)
I think the OP is going after displaying a "legend" for the usergroups though ;)

Which, if you did a search for legend there are already several mods for this :p

kh99
01-25-2012, 09:14 PM
Which, if you did a search for legend there are already several mods for this :p

lol...Thanks Brooks - and sorry Clydesdale, sometimes I forget to check for an existing mod. :o

Clydesdale
01-25-2012, 10:49 PM
lol...Thanks Brooks - and sorry Clydesdale, sometimes I forget to check for an existing mod. :o

That makes two of us..... Sucks being the uber-novice!