PDA

View Full Version : Images displayed before Username for certain Usergroups


Brexen
06-05-2012, 08:52 AM
Hi Guys,

I need to know if there is a plugin out there, that allows me to set an option to display an image before the username; if a user is in a certain usergroup. If not, how would I go about creating one, so it displays everywhere on my forum?

I know this can be done with HTML Mark-up, but I want it done my way, so that the HTML Mark-up of this group, don't interfere with other Usergroups.

Example: A user can be Premium and apart of this group with the image still displayed left of their username, without affecting the username colour.

Any help is appreciated.

kh99
06-05-2012, 09:31 AM
I'm not sure if this exists already, but you could create a plugin using hook fetch_musername and add image code to $user['musername']. Like:

if (is_member_of($user, X))
{
$user['musername'] = "<img src='images/someimg.gif'>" . $user['musername'];
}

Brexen
06-05-2012, 10:06 AM
I'm not sure if this exists already, but you could create a plugin using hook fetch_musername and add image code to $user['musername']. Like:

if (is_member_of($user, X):
{
$user['musername'] = "<img src='images/someimg.gif'>" . $user['musername'];
}

Thanks Kh99,

But is this;

If User is UserID add image or If user is a member of UsergroupID add images?

The second would be preferred ofcourse, but I shall try this nonetheless.

kh99
06-05-2012, 10:15 AM
Thanks Kh99,

But is this;

If User is UserID add image or If user is a member of UsergroupID add images?



The second one. 'X' is a groupid, and can be the primary group or any secondary group. (BTW, you can also list more values if you want, like is_member_of($user, X, Y, Z...);)

Brexen
06-05-2012, 10:25 AM
The second one. 'X' is a groupid, and can be the primary group or any secondary group. (BTW, you can also list more values if you want, like is_member_of($user, X, Y, Z...);)

Returned a lovely error.


Parse error: syntax error, unexpected ':' in /home/tactical/public_html/includes/functions.php(1620) : eval()'d code on line 3


I'm using it on my test forum, before I try it on my main.

kh99
06-05-2012, 10:28 AM
Oops, there was a typo - should have been ')' instead of ':' -

if (is_member_of($user, X))
{
$user['musername'] = "<img src='images/someimg.gif'>" . $user['musername'];
}


Also you need to be careful to use single quotes in your img tag.

If you still get an error, post your exact code here.

Brexen
06-05-2012, 10:36 AM
Works brilliantly, thanks KH99, great help as always.

Also to anyone who's trying this and wants text to be displayed when hovering over the Image.

Change this:


<img src='X'>


to this;


<img src='X' title='Y'>


Where X = image URL, and Y = Text to be displayed.

Tested and working

http://screensnapr.com/e/4ybRYT.png