News:

Create A Forum Installed

Author Topic: Color username based on membergroup?  (Read 866 times)

0 Members and 3 Guests are viewing this topic.

Offline Nienna

  • Newbie
  • *
  • Posts: 3
  • Karma: 1
    • View Profile

Badges: (View All)
Topic Starter First Post Level 1
Color username based on membergroup?
« on: February 06, 2013, 08:15:32 pm »
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?

Share on Facebook Share on Twitter


Offline CreateAForum

  • Administrator
  • *****
  • Posts: 7186
  • Karma: 327
    • View Profile

Badges: (View All)
Avatar Linux User Tenth year Anniversary
Re: Color username based on membergroup?
« Reply #1 on: February 06, 2013, 08:18:58 pm »
Did you include the jquery call/load from the top of membergroup color topic?
Like Create A Forum? Support me at https://www.patreon.com/vbgamer45/

Offline Nienna

  • Newbie
  • *
  • Posts: 3
  • Karma: 1
    • View Profile

Badges: (View All)
Topic Starter First Post Level 1
Re: Color username based on membergroup?
« Reply #2 on: February 06, 2013, 08:21:03 pm »
Yes I did (otherwise the code wouldn't work for the background of the post either) ;)

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile

Badges: (View All)
Level 6 Sixth year Anniversary Fifth year Anniversary
Re: Color username based on membergroup?
« Reply #3 on: February 06, 2013, 09:17:51 pm »
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.

Offline Nienna

  • Newbie
  • *
  • Posts: 3
  • Karma: 1
    • View Profile

Badges: (View All)
Topic Starter First Post Level 1
Re: Color username based on membergroup?
« Reply #4 on: February 07, 2013, 10:50:02 am »
Thank you very much, this did the trick!


And sorry about posting in the wrong board, I'll keep it in mind for next time.

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
1198 Views
Last post March 19, 2011, 11:55:09 am
by Thornton136
6 Replies
865 Views
Last post March 27, 2011, 01:17:06 pm
by MCschematics
1 Replies
877 Views
Last post November 04, 2012, 05:08:10 pm
by aIURbliS
9 Replies
2766 Views
Last post March 13, 2013, 10:51:19 pm
by aIURbliS
4 Replies
1269 Views
Last post March 06, 2013, 08:42:22 pm
by AnonyMister