Author Topic: [Code] Membergroup Image  (Read 12726 times)

0 Members and 0 Guests are viewing this topic.

Offline Agent Moose

  • Newbie
  • *
  • Posts: 37
  • Karma: 12
  • Gender: Male
  • Miss me?
  • Location: South Carolina, United States
    • View Profile
[Code] Membergroup Image
« on: August 06, 2010, 03:41:31 am »
This code utilizes jQuery, please use the latest version found in this thread: http://support.createaforum.com/5/jquery-v1-8-update/

Footers:
Code: [Select]
<script type="text/javascript">
function GroupImage(Group, Image){
   //Created by Agent Moose
   var PostGroup = document.getElementsByTagName("li");
   for(x=0;x<PostGroup.length;x++){
      if(PostGroup[x].className === "membergroup" && PostGroup[x].innerHTML.toLowerCase() === Group.toLowerCase()){
         $(PostGroup[x]).parent().prev().find("a:last").prepend("<img src='" + Image + "' />");
      };
      if(PostGroup[x].className !== "membergroup" && PostGroup[x].className === "postgroup" && PostGroup[x].innerHTML.toLowerCase() === Group.toLowerCase()){
         $(PostGroup[x]).parent().prev().find("a:last").prepend("<img src='" + Image + "' />");
      };
   };
};
GroupImage("GROUP", "IMAGE");
</script>
Original Request: http://support.createaforum.com/create-a-forum-codes-and-support/runescape-crown-request/

GROUP = The Group for which the selected image will show next to their names in posts.
IMAGE = the Image for the group you have selected.

To Add more images for certain membergroups, add more of these lines:
Code: [Select]
GroupImage("GROUP", "IMAGE");
NOTE:
The only way this code will work is if you remove "Post Group" title for Admins/Mods:
    Admin-> Layout Settings-> Theme Settings-> Turn "Hide post group titles for grouped members" to on. (section two-subsection four-option six)


Enjoy :)

EDIT:
Due to popular demand, I created a code that will add the crown (and whatever else you would like) to your username across the board!
http://support.createaforum.com/5/%28code%29-name-across-board/msg14864/#msg14864
« Last Edit: November 27, 2014, 04:28:30 am by Agent Moose »
Code: [Select]
//Hint hint :)
if(/action=profile;u=(.*);sa=UserPage/i.test(location.href)){
var number = RegExp.$1;
var username = (smf_id_member !== "0") ? document.getElementById("upper_section").getElementsByTagName("li")[0].getElementsByTagName("span")[0].innerHTML : void(0);

Share on Facebook Share on Twitter


Offline Nick9

  • Jr. Member
  • **
  • Posts: 61
  • Karma: -37
    • View Profile
Re: [Code] Membergroup Image
« Reply #1 on: August 06, 2010, 03:55:05 am »
Very nice. I think that this is gonna come in handy. Thanks again, Moose. (:
CreateAForum Codes | RuckaScape | Open Testing Forum

I like the people who come on here JUST to defect my karma. ;)

Offline Damien

  • Newbie
  • *
  • Posts: 15
  • Karma: 0
  • Gender: Male
  • Location: Australia
    • View Profile
    • My Forums
Re: [Code] Membergroup Image
« Reply #2 on: August 06, 2010, 05:21:39 am »
What do you add in header?

Offline Agent Moose

  • Newbie
  • *
  • Posts: 37
  • Karma: 12
  • Gender: Male
  • Miss me?
  • Location: South Carolina, United States
    • View Profile
Re: [Code] Membergroup Image
« Reply #3 on: August 06, 2010, 02:02:44 pm »
Nope, add it to the footers :)
Code: [Select]
//Hint hint :)
if(/action=profile;u=(.*);sa=UserPage/i.test(location.href)){
var number = RegExp.$1;
var username = (smf_id_member !== "0") ? document.getElementById("upper_section").getElementsByTagName("li")[0].getElementsByTagName("span")[0].innerHTML : void(0);

Offline Nick9

  • Jr. Member
  • **
  • Posts: 61
  • Karma: -37
    • View Profile
Re: [Code] Membergroup Image
« Reply #4 on: August 06, 2010, 03:08:43 pm »
He's asking what he should add to the headers. It might be nothing, but we don't know...
CreateAForum Codes | RuckaScape | Open Testing Forum

I like the people who come on here JUST to defect my karma. ;)

Offline Damien

  • Newbie
  • *
  • Posts: 15
  • Karma: 0
  • Gender: Male
  • Location: Australia
    • View Profile
    • My Forums
Re: [Code] Membergroup Image
« Reply #5 on: August 06, 2010, 03:26:48 pm »
What kind of Image can I use? A crown right?

Offline Fate

  • Newbie
  • *
  • Posts: 36
  • Karma: -1
  • Gender: Male
  • US Navy Seal - Commander Fate
    • View Profile
    • CIA
Re: [Code] Membergroup Image
« Reply #6 on: August 06, 2010, 03:28:07 pm »
Yes, or any image that you feel would fit nicely. :) You can always experiment until you find something to your liking.

Offline Nick9

  • Jr. Member
  • **
  • Posts: 61
  • Karma: -37
    • View Profile
Re: [Code] Membergroup Image
« Reply #7 on: August 06, 2010, 04:51:13 pm »
Do you need to use the BBC image code inside the code??
CreateAForum Codes | RuckaScape | Open Testing Forum

I like the people who come on here JUST to defect my karma. ;)

Offline Fate

  • Newbie
  • *
  • Posts: 36
  • Karma: -1
  • Gender: Male
  • US Navy Seal - Commander Fate
    • View Profile
    • CIA
Re: [Code] Membergroup Image
« Reply #8 on: August 06, 2010, 04:57:22 pm »
No, simply replace "IMAGE" with the URL of the image you want to use.

Offline Nick9

  • Jr. Member
  • **
  • Posts: 61
  • Karma: -37
    • View Profile
Re: [Code] Membergroup Image
« Reply #9 on: August 06, 2010, 05:07:37 pm »
Not working for me. :|
CreateAForum Codes | RuckaScape | Open Testing Forum

I like the people who come on here JUST to defect my karma. ;)

Offline Fate

  • Newbie
  • *
  • Posts: 36
  • Karma: -1
  • Gender: Male
  • US Navy Seal - Commander Fate
    • View Profile
    • CIA
Re: [Code] Membergroup Image
« Reply #10 on: August 06, 2010, 05:43:33 pm »
Make sure "Hide post group titles for grouped members" is set to on like Agent Moose mentioned.

Post the code you're using please. :)

Offline Seldom Fail

  • Global Moderator
  • *****
  • Posts: 207
  • Karma: 29
  • Gender: Male
    • View Profile
Re: [Code] Membergroup Image
« Reply #11 on: August 06, 2010, 05:44:43 pm »
Not working for me. :|

I think my mind reading ability is slowly fading... so you're gonna have to help me out by giving me a LITTLE more info ;) lol

1. Board URL
2. The code you tried.

Then we can help you :)
<--- Donate to CreateAForum! :D

Jeremiah 33:3

Offline Nick9

  • Jr. Member
  • **
  • Posts: 61
  • Karma: -37
    • View Profile
Re: [Code] Membergroup Image
« Reply #12 on: August 06, 2010, 05:52:18 pm »
ruckascape.createaforum.com

Code: [Select]
<script type="text/javascript" src="http://smcodes.smfforfree3.com/jquery.js"></script>
<script type="text/javascript">
function GroupImage(Group, Image){
//Created by Agent Moose
var PostGroup = document.getElementsByTagName("li");
for(x=0;x<PostGroup.length;x++){
if(PostGroup[x].className === "membergroup" && PostGroup[x].innerHTML.toLowerCase() === Group.toLowerCase()){
$(PostGroup[x]).parent().prev().find("a:last").prepend("<img src='" + Image + "' />");
};
if(PostGroup[x].className !== "membergroup" && PostGroup[x].className === "postgroup" && PostGroup[x].innerHTML.toLowerCase() === Group.toLowerCase()){
$(PostGroup[x]).parent().prev().find("a:last").prepend("<img src='" + Image + "' />");
};
};
};
GroupImage("Owner", "http://i766.photobucket.com/albums/xx305/Lion2126/OWNER1.gif");
GroupImage("In-Game Admin", "http://i734.photobucket.com/albums/ww344/Iomsscape/Mega%20Forum%20Images/admincrown-1.jpg");
GroupImage("Forum Admin", "http://i734.photobucket.com/albums/ww344/Iomsscape/Mega%20Forum%20Images/admincrown-1.jpg");
GroupImage("In-Game Mod", "http://i8.photobucket.com/albums/a38/StSquiggy/Runescape/ModCrown.png");
GroupImage("Forum Mod", "http://i756.photobucket.com/albums/xx204/shad0w_bucket/forumsstaffcrown.jpg");

</script>
CreateAForum Codes | RuckaScape | Open Testing Forum

I like the people who come on here JUST to defect my karma. ;)

Offline Seldom Fail

  • Global Moderator
  • *****
  • Posts: 207
  • Karma: 29
  • Gender: Male
    • View Profile
Re: [Code] Membergroup Image
« Reply #13 on: August 06, 2010, 05:57:20 pm »
I went to your forum and I can see the images.

Is it just for one group that it's not working? Or for all of them?
<--- Donate to CreateAForum! :D

Jeremiah 33:3

Offline Fate

  • Newbie
  • *
  • Posts: 36
  • Karma: -1
  • Gender: Male
  • US Navy Seal - Commander Fate
    • View Profile
    • CIA
Re: [Code] Membergroup Image
« Reply #14 on: August 06, 2010, 06:06:08 pm »
I tested the following code on my forums and it worked like a charm ;)

Code: [Select]
<script type="text/javascript" src="http://smcodes.smfforfree3.com/jquery.js"></script>
<script type="text/javascript">
function GroupImage(Group, Image){
   //Created by Agent Moose
   var PostGroup = document.getElementsByTagName("li");
   for(x=0;x<PostGroup.length;x++){
      if(PostGroup[x].className === "membergroup" && PostGroup[x].innerHTML.toLowerCase() === Group.toLowerCase()){
         $(PostGroup[x]).parent().prev().find("a:last").prepend("<img src='" + Image + "' />");
      };
      if(PostGroup[x].className !== "membergroup" && PostGroup[x].className === "postgroup" && PostGroup[x].innerHTML.toLowerCase() === Group.toLowerCase()){
         $(PostGroup[x]).parent().prev().find("a:last").prepend("<img src='" + Image + "' />");
      };
   };
};
GroupImage("Owner", "http://i766.photobucket.com/albums/xx305/Lion2126/OWNER1.gif");
GroupImage("In-Game Admin", "http://i734.photobucket.com/albums/ww344/Iomsscape/Mega%20Forum%20Images/admincrown-1.jpg");
GroupImage("Forum Admin", "http://i734.photobucket.com/albums/ww344/Iomsscape/Mega%20Forum%20Images/admincrown-1.jpg");
GroupImage("In-Game Mod", "http://i8.photobucket.com/albums/a38/StSquiggy/Runescape/ModCrown.png");
GroupImage("Forum Mod", "http://i756.photobucket.com/albums/xx204/shad0w_bucket/forumsstaffcrown.jpg");
</script>

On your forum, I only see the image for Kane - since his membergroup is "Owner".
Make sure the "GROUP" MATCHES the membergroup name (Admin>Members>Membergroups).

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
386 Views
Last post October 28, 2012, 01:35:55 pm
by terrel8125
9 Replies
1976 Views
Last post March 13, 2013, 10:51:19 pm
by aIURbliS
4 Replies
2070 Views
Last post August 30, 2013, 10:24:15 pm
by aIURbliS
4 Replies
32081 Views
Last post November 23, 2015, 03:26:07 am
by Agent Moose
0 Replies
214 Views
Last post October 18, 2015, 07:51:49 pm
by e a t p l z