Skip to content

Color username based on membergroup?

1962 Views 4 Replies

0 Members and 1 Guest are viewing this topic.

Color username based on membergroup?
on:
#1
Hi there,


On my forum, I have (of course) several membergroups and I'd like to be able to distinguish them clearly. I am looking for a code that will change the color of the poster that appears next to the post, based on membergroup. For example, I am an Administrator, and the color of Administrators is gold on my forum, so I would like my name to appear in gold next to my posts.


Now when searching this forum, I found this topic on changing the background of a post, based on a membergroup. I tried tweaking it so it would not change the background, but the color of the username, but obviously I didn't succeed. (I inserted the code correctly, since it would change the background to gold before trying to tweak it).
Now this is the code I tried (after I tweaked it a bit):


Code: [Select]

<script>
function xboi209_colormembergroupposts(membergroup,color){$("li.membergroup:contains('"+membergroup+"')").closest(".poster h4 a").css("color",color)}xboi209_colormembergroupposts("Administrator","gold");
</script>


Could anybody help me?
Re: Color username based on membergroup?
Reply #3 on:
#4
Code: [Select]
<script>function xboi209_colormembergroupposts(a,b){$("li.membergroup:contains('"+a+"')").each(function(){$(this).closest("div.poster").children("h4").children("a").eq(1).css("color",b)})}xboi209_colormembergroupposts("Administrator","gold");</script>
It would have been nice if you posted in the codes support board.
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.