User-Selectable Ranks (phpBB3 and IPB2/Invision)
Posted November 10th 2011, 9:10pm
This little trick will give you the ability to add a second rank to each post profile, and optionally, allow the member to set their own custom rank.

This script is NOT an example tutorial in the Javascript 101 forum -- it is in a members-only forum, so please do not post links to this topic. And as always, please respect my copyright -- do not post this code anywhere nor give it to anyone else! In addition, please do not ask about a PunBB version, because I will not be writing one. However, I would be thrilled if a member modified the script to work on PunBB boards, and posted the modified script as a reply in this topic!

First, go to ACP>Users&Groups>Profiles and click on the "+" sign at the bottom right to add a new profile field. Select the following options:

Type: Text Field
Name: Custom Rank (It must be EXACTLY this name!!!)
Color: Leave blank!
Description: Whatever you want
URL Icon: Leave blank!
Necessarily Filled: No
Display: Profile AND Messages
Display Type: Text
Modify: Moderators, and members if you want members to set their own custom ranks
Display: Guests or Members, your choice
Separator: Horizontal Bar

Set the maximum length to whatever you want. Please note that you CANNOT change these settings unless I said it was OK to do so above! The script depends on several of these settings in order to work.

Once you have this filled out, click Save and make sure the "Custom Rank" field is at the top of the list. It MUST be at the top, or the script will not work!

Finally, place the following code in a javascript file. It can be in its own file, or you can add it to the bottom of a javascript file you have already created.

var CopyrightNotice = 'User-Selectable ranks for forumotion phpBB3 and IPB2/Invision boards. Copyright © 2011 by Dion Designs. All Rights Reserved. Personal use and/or modification of this script is allowed, provided this entire copyright notice remains in the original or modified script. Distribution is not allowed without written consent from Dion Designs.';

$(function() {
    var x=$('.postprofile').get();
    for (i=0; i<x.length; i++) {
        var y=x[i].getElementsByTagName('HR')[0];
        if (y) {
            var rank=y.nextSibling.nodeValue;
            if (rank.substring(0,1)==' ') {rank=rank.substring(1);}
            if (y.innerHTML=='Custom Rank: ') {
                var z=x[i].getElementsByTagName('DD')[0];
                z.innerHTML+='<div class="customrank">' + rank + '</div>';

And finally, if you want to format the new rank, you can do so with the following CSS:

.customrank {your CSS here}

That's it! You will now have a new profile field called "Custom Rank", and whatever you put in that field will show up as a rank. If the member already has a rank, the custom rank will be displayed below the "official" rank.

This gives you a lot of flexibility in setting up ranks for members. You can now have post-based ranks AND custom ranks like "Administrator". Or you can keep your current ranks and let members have some fun!
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
User-Selectable Ranks (phpBB3 and IPB2/Invision)
Posted December 11th 2011, 2:01pm
Thanks Dion..

love it x3
Posts: 15
Joined: September 22nd 2011, 11:00pm
Location: Yoshi's Island

Who is online

Users browsing this forum: No registered users and 0 guests