PDA

View Full Version : Custom Rank Image for each User


Marris
01-13-2006, 10:00 PM
Custom Rank Image for each User HACK
------------------------------------
version 1.0 (beta)
by Marris
January 14, 2006
for vBulletin 3.5.3

Lastest version, discussion and screenshots at:
URL: https://vborg.vbsupport.ru/showthread.php?t=105286

Requires: 2 plugins, 2 or 3 template edits, 1 new profile field.

Templates to Edit:

MEMBERINFO
postbit
postbit_legacy (optional)

Time to install: 15-20 min.

*NOTE: This code will NOT work as-is on 3.5.0 boards. See trackpads' post (https://vborg.vbsupport.ru/showthread.php?p=875866#post875866) for some information regarding the difference between the 3.5.3 and 3.5.0 bbcode parsing that may help you get it working on an earlier version.
---------------------------

(*The basic plugin code for steps 2 and 3 of this hack was originally posted HERE (https://vborg.vbsupport.ru/showpost.php?p=829863&postcount=151) by The Geek (https://vborg.vbsupport.ru/member.php?u=41852). It has only been modified to parse image tags rather than links. The Geek, please let me know if you want official co-credit for this hack.)


What it does: This hack allows the Admin to set a Custom Rank Image for individual users by entering a bbcode image link in a custom profile field.

So for example, if your forum has stars as the standard rank image, you could set one user to have flowers and another to have dollar bills (or whatever).

Why: Yes, I know vB 3.5 already has multiple ranks, but they are determined by usergroup, not individual user. I recently converted to vB from another forum that allowed per user rank images, so I have many users with custom rank images. Without this hack, I had to 1) make a new usergroup for each custom rank used by a single member, 2) add the user to that group, then 3) set each user display group to that group.

With the number of users who have Custom Ranks on my forum, not only is this a tedious process, but it also adds a ton of clutter in the Usergroups and Permissions settings.

What it doesn't do: This doesn't set multiple variable rank images. You can only have one rank image per user, rather than a progression of images. This means you either have to manually change the image link when the user advances, or do what I do, which is just set each users custom rank to the maximum in the first place. (Custom rank images are a special perk for forum leaders.)

This hack is only worthwhile if you have a need for many Custom Rank Images for individual users like I do. If you only have a handful, just making new usergroups and ranks the normal way is probably quicker and easier.

Requires: 2 plugins, 2 or 3 template edits, 1 new profile field.

How to install:

0. If you have not installed any Plugins before, make sure you activate the Plugin system. In the main vBulletin Options > Plugin/Hook System : check YES to Enable Plugin/Hook System.

1. In Admin CP > User Profile Fields > Add New User Profile Field, create:

Profile Field Type: Single-Line Text Box

Title: Custom Rank Image

Max length of allowed user input: 400

Field Required: No

Field Editable by User: No

Private Field: No

Field Searchable on Members List: No

Show on Members List: No

Display Page: Edit Profile

Then SAVE.

In the User Profile Field Manager, note the Name of the newly created field. You will need it for the next step. For this example I will use: field99

***IMPORTANT: Do not just cut and paste the code below, or it will not work. In each code snippet below, you must manually replace field99 with the Name of your newly created Profile Field above.

2. In Admin CP > Plugin System > Add New Plugin

Hook Location: postbit_display_complete

Title: Custom Rank Image in postbit

Plugin PHP Code:

*IMPORTANT: You must replace field99 with the field Name of your newly created field in three locations in the following code:

if ($post['field99'])
{
if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
}
$post['field99'] = $bbcode_parser->parse($post['field99'],3, true);
}

Then SAVE.

3. Create a second new plugin. In Admin CP > Plugin System > Add New Plugin

Hook Location: member_complete

Title: Custom Rank Image in MEMBERINFO

Plugin PHP Code:

*IMPORTANT: Again, you must replace field99 with the field Name of your newly created field in three locations in the following code:

if ($userinfo['field99'])
{
if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
}
$userinfo['field99'] = $bbcode_parser->parse($userinfo['field99'],3, true);
}


Then SAVE.

The purpose of the two plugins is to allow bbcode IMG tags in Profile field field99.

*This basic plugin code was originally posted HERE (https://vborg.vbsupport.ru/showpost.php?p=829863&postcount=151) by The Geek (https://vborg.vbsupport.ru/member.php?u=41852). It has only been modified to parse image tags rather than links.

4. In Admin CP > Styles & Templates > Style Manager, selct your current style and Edit Templates.

Select MEMBERINFO and press Customize or EDIT. I recommend you check the Save in Template History?: YES box and press the Save & Reload button, before editing, in case you want to go back to your previous template.

FIND around line 23:

<if condition="$userinfo['rank']"><div align="center">$userinfo[rank]</div></if>

REPLACE WITH:

*IMPORTANT: Yet again, you must replace field99 with the field Name of your newly created field in two locations in the following code:

<if condition="$userinfo['field99']"><div align="center">$userinfo[field99]</div>
<else />
<if condition="$userinfo['rank']"><div align="center">$userinfo[rank]</div></if>
</if>

Then SAVE.

* The following step 5 only applies if you are using the standard postbit. If you are using postbit_legacy, skip down to step 6. If you are using both postbit and postbit_legacy, you must do both steps 5 and 6.

5. In Admin CP > Styles & Templates > Style Manager, selct your current style and Edit Templates.

Select postbit and press Customize or EDIT. Again, I recommend you check the Save in Template History?: YES box and press the Save & Reload button, before editing, in case you want to go back to your previous template.

FIND around line 55:

<if condition="$post['rank']"><div class="smallfont">$post[rank]</div></if>

REPLACE WITH:

*IMPORTANT: As usual, you must replace field99 with the field Name of your newly created field in two locations in the following code:

<if condition="$post['field99']"><div class="smallfont">$post[field99]</div>
<else />
<if condition="$post['rank']"><div class="smallfont">$post[rank]</div></if>
</if>

Then SAVE.

* The following step 6 only applies if you are using the postbit_legacy. If not, you can skip down to step 7.

6. In Admin CP > Styles & Templates > Style Manager, selct your current style and Edit Templates.

Select postbit_legacy and press Customize or EDIT. Again, I recommend you check the Save in Template History?: YES box and press the Save & Reload button, before editing, in case you want to go back to your previous template.

FIND around line 45:

<if condition="$post['rank']"><div class="smallfont">$post[rank]</div></if>

REPLACE WITH:

*IMPORTANT: Again, for the last time, you must replace field99 with the field Name of your newly created field in two locations in the following code:

<if condition="$post['field99']"><div class="smallfont">$post[field99]</div>
<else />
<if condition="$post['rank']"><div class="smallfont">$post[rank]</div></if>
</if>

Then SAVE.

Now, you are basically finished with the install, but to test it out, go on to the last step:

7. Upload a new image for your Custom Rank Image to your server by your preferred method, FTP, Gallery, Photopost, Photoplog or whatever. OR you can just use one of your existing rank images to test.

In Admin CP > Users > Search for Users, input the User Name and press Exact Match.

Now, scroll down to the User Profile Fields, and you should have an input field called Custom Rank Image. In that field, enter the full URL to your test rank image within IMG tags:

http://www.yourdomain.com/forum/images/ranks/testrank.gif

Then SAVE.

Now, view that user's Public Profile and look at some of their posts to confirm that the new custom rank image is showing up.

If it is, then you're done. To set a Custom Rank Image for another user, just repeat the above procedure, adding an IMG link to that user's Custom Rank Image User Profile Field in the Admin CP > User Manager. To remove the custom rank image, just clear the value of Custom Rank Image in the User Profile Field and save. Then the users rank image should revert to whatever it was before, as determined by their standard usergroup rank display settings.

If not, double-check all the steps again and make sure you don't have any typos. Also make sure you don't already have other hacks installed that might cause a conflict.

END of Install
-------------
-------------

TO UNINSTALL (untested):

Reverse the Template edits above, delete the 2 Plugins you added and delete the new User Profile Field you created.

-------------------------------------------------

I have only tested the configuration above, but it might be possible to set Field Editable by User: YES and allow users to set their own rank images. I cannot say if that will work or not, and unless you had some way to control the size of the users linked image, it might break the formatting of your threads.

UPDATE: Another untested alternative use occurs to me: If you change the <if><else/></if> to a discreet <if></if> in each template edit around the line that displays your Custom Rank Image profile field, you could use this as a second or additional rank above, below or beside your existing usergroup ranks.

UPDATE:

Added a textfile with instructions. Please excuse the formatting.

Also added screenshots of the new User Profile Field option in the Admin CP and a before and after shot.

UPDATE: Added Step 0, to make sure you have the vBulletin Plugin System enabled on you forum.

UPDATE: This code will NOT work as-is on 3.5.0 boards. See trackpads' post (https://vborg.vbsupport.ru/showthread.php?p=875866#post875866) for some information regarding the difference between the 3.5.3 and 3.5.0 bbcode parsing that may help you get it working on an earlier version.

I'm a beginner at this stuff, so I'm not sure how much help I can be troubleshooting or improving the hack, but maybe some more experienced coders will be able to come up with the answers.

Please click INSTALL (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=105286) if you use this hack.
--------------------------------------------------
*The basic plugin code for steps 2 and 3 of this hack was originally posted HERE (https://vborg.vbsupport.ru/showpost.php?p=829863&postcount=151) by The Geek (https://vborg.vbsupport.ru/member.php?u=41852). It has only been modified to parse image tags rather than links.

Barakat
01-14-2006, 12:02 PM
i will try it thanks .

Marris
01-14-2006, 12:30 PM
You're welcome. I hope it's useful for you.

dcarr
01-14-2006, 02:47 PM
This may be just what i was looking for. But could you put it all into a text file please? Thank you.

Snake
01-14-2006, 03:51 PM
How about a few screenshots please?

Marris
01-14-2006, 09:20 PM
Added a textfile with instructions. Please excuse the formatting.

Also added screenshots of the new User Profile Field option in the Admin CP and a before and after shot.

If, for example, you do follow the instructions and put the IMG link to the user's existing current default rank image in the Custom Rank Image field, the postbit would look exactly the same as before. But with this hack you can change a single user's rank image at will without adding an extra usergroup.

Of course, you will have to make and upload your own Custom Rank Image file for each user, unless you want more than one user to share the same image.

trackpads
01-16-2006, 01:50 PM
Added a textfile with instructions. Please excuse the formatting.

Also added screenshots of the new User Profile Field option in the Admin CP and a before and after shot.

If, for example, you do follow the instructions and put the IMG link to the user's existing current default rank image in the Custom Rank Image field, the postbit would look exactly the same as before. But with this hack you can change a single user's rank image at will without adding an extra usergroup.

Of course, you will have to make and upload your own Custom Rank Image file for each user, unless you want more than one user to share the same image.

Ok, definately stumped here. I really love this idea but for some reason I cannot get it to work.

Instead of the rank it displays the actual text that I put into the Custom User field, IMG tag and all.

I have verified the tag by putting it in a post and it works fine, for some reason the plugins are not parsing the bb code. Any ideas?

Thanks again!

Marris
01-16-2006, 10:58 PM
Ok, definately stumped here. I really love this idea but for some reason I cannot get it to work.

Instead of the rank it displays the actual text that I put into the Custom User field, IMG tag and all.

I have verified the tag by putting it in a post and it works fine, for some reason the plugins are not parsing the bb code. Any ideas?

Thanks again!

Are you using vBulletin version 3.5.3? That's the only version I've tried it on.

Double check that you followed steps 2 and 3 exactly.

Check the hook locations and make sure you have replaced field99 with the field Name of your own Custom Profile Field.

You can see the Field Name in the User Profile Field Manager in the Name column. It should be in the format fieldx (where x is a number). You should NOT be using the Profile Title to replace field99.

Also note the plugins are not exactly the same, step two uses $post, while step 3 uses $userinfo. Also make sure the plugins are Active (tick the checkbox).

Also double check the main vBulletin Options > Plugin/Hook System : check YES to Enable Plugin/Hook System.

That last one is my omission, I will update the first post. If you didn't have any Plugins active before this, you might not have had it enabled.

If none of those suggestions get it working, then I'm not sure what to try next. Maybe look for conflicts with other hacks you have installed.


---

A general note: On my own forum, I have successfully completed converting all my members that previously used the built-in usergroups/ranks system for single user rank images to this Custom Rank Images hack. I removed the old rank images and deleted the usergroups and everything seems to be working fine.

I am using this hack only for single user ranks, the bulk of my users' ranks are still determined by the standard Rank Image system for the default Registered Users group.

Permissions and usergroups are a lot easier to manage with a fraction of the usergroups I used to have, and it's a snap to add a new Custom Rank Image for additional users now.

trackpads
01-17-2006, 12:19 AM
Are you using vBulletin version 3.5.3? That's the only version I've tried it on.

Double check that you followed steps 2 and 3 exactly.

Check the hook locations and make sure you have replaced field99 with the field Name of your own Custom Profile Field.

You can see the Field Name in the User Profile Field Manager in the Name column. It should be in the format fieldx (where x is a number). You should NOT be using the Profile Title to replace field99.

Also note the plugins are not exactly the same, step two uses $post, while step 3 uses $userinfo. Also make sure the plugins are Active (tick the checkbox).

Also double check the main vBulletin Options > Plugin/Hook System : check YES to Enable Plugin/Hook System.

That last one is my omission, I will update the first post. If you didn't have any Plugins active before this, you might not have had it enabled.

If none of those suggestions get it working, then I'm not sure what to try next. Maybe look for conflicts with other hacks you have installed.


---

A general note: On my own forum, I have successfully completed converting all my members that previously used the built-in usergroups/ranks system for single user rank images to this Custom Rank Images hack. I removed the old rank images and deleted the usergroups and everything seems to be working fine.

I am using this hack only for single user ranks, the bulk of my users' ranks are still determined by the standard Rank Image system for the default Registered Users group.

Permissions and usergroups are a lot easier to manage with a fraction of the usergroups I used to have, and it's a snap to add a new Custom Rank Image for additional users now.

I am using 3.5 (with the hotfixes) so I dont know if that has something to do with it. I should hope not.

I have went through all my plugins and tried disabling everyone that uses the member_complete for example but no luck. Its already late tonight so I will try a mass disable tomorrow and see if I can find the culprit.

Thanks again,

-Jason

trackpads
01-17-2006, 02:49 PM
Marris!

thanks for the fix! Taht did it. I am using the old Friendster style hack and that must be like the myspace thingy because that is the one that fixed it.

Thanks again!!!

trackpads
01-17-2006, 10:26 PM
Marris!

thanks for the fix! Taht did it. I am using the old Friendster style hack and that must be like the myspace thingy because that is the one that fixed it.

Thanks again!!!

Ok, rats. Taht fixed it on my profile pages but not in the postbit. I tried reactivation the postbit plugin but still no luck.

Any ideas?

Thanks again for all the help,

-Jason

trackpads
01-17-2006, 11:08 PM
Got it!

Using this guide:

https://vborg.vbsupport.ru/showthread.php?t=82693&highlight=bbcode+parsing

I realized that since I am using 3.5 core then the codes are different, I changed it to this and it worked like a charm!


if ($post['field29'])
{
if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
$parsed_text = $parser->do_parse($text, $do_html, $do_smilies, $do_bbcode, $do_imgcode, $do_nl2br, $cachable);
}
$post['field29'] = $parser->do_parse($post['field29']);
}



Now for other pages my ranks are on :)

Marris
01-17-2006, 11:41 PM
Got it!

Using this guide:

https://vborg.vbsupport.ru/showthread.php?t=82693&highlight=bbcode+parsing

I realized that since I am using 3.5 core then the codes are different, I changed it to this and it worked like a charm!

Now for other pages my ranks are on :)

Glad to hear you got it working! Did you click Install (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=105286)? ;)

To clarify some points, so I can add notes to the original post, is your code snippet only for postbit_display_complete? And then you used my Step 3. code for member_complete/MEMBERINFO? Or did you have also to use your new $parsed_text method for the member_complete Plugin?

Also, does your 3.5 core bbcode parsing method only apply to 3.5.0, or does it also include either 3.5.1 or 3.5.2?

Thanks.

trackpads
01-18-2006, 09:18 AM
Glad to hear you got it working! Did you click Install (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=105286)? ;)

To clarify some points, so I can add notes to the original post, is your code snippet only for postbit_display_complete? And then you used my Step 3. code for member_complete/MEMBERINFO? Or did you have also to use your new $parsed_text method for the member_complete Plugin?

Also, does your 3.5 core bbcode parsing method only apply to 3.5.0, or does it also include either 3.5.1 or 3.5.2?

Thanks.

Definately clicked install!

I used the other myspace bbcode for the member info to get it to work, but as soon as I get a chance I am gonna go back and try editing for the new parse string.

I am not sure which versions this applies to but during the next 4 day weekend I am going to upgrade to 3.53 and see.

Thanks again!!!

-Jason

Marris
01-18-2006, 09:23 AM
Definately clicked install!

I used the other myspace bbcode for the member info to get it to work, but as soon as I get a chance I am gonna go back and try editing for the new parse string.

I am not sure which versions this applies to but during the next 4 day weekend I am going to upgrade to 3.53 and see.

Thanks again!!!

Great, thanks a lot! I'll update the first post with your findings.

Matt_270581
03-04-2006, 10:46 AM
Was looking for something like this as the Default user ranks only work per group and some groups have multiple members so it is hard to manage if I want to apply a user rank image to a particular user. Thanks. Will try to install later.

Station
04-28-2006, 01:45 AM
I tried installing this at my forum and whatever thread that contains a post from a user I set a custom rank on, it gives me this error:Fatal error: Call to a member function on a non-object in /forums/includes/class_bbcode.php on line 181

I went back and checked. Plugins are turned on in vBoptions and I triple checked the code for both plugins and the templates.

I am on 3.5.4, does that have anything to do with the problem?

tappedout
05-12-2006, 10:29 AM
Wow what an amazing difference a little mod like this can make! I had so many different usergroups it was making my head spin....Thanks a ton for thinking of the little things!! *Clicked Install!!! :banana:

good2laugh
05-22-2006, 05:28 AM
I tried installing this at my forum and whatever thread that contains a post from a user I set a custom rank on, it gives me this error:

I went back and checked. Plugins are turned on in vBoptions and I triple checked the code for both plugins and the templates.

I am on 3.5.4, does that have anything to do with the problem?


I have exactly the same error, and am also running 3.54, this is such a fab idea I really want to get it to work - anyone can help resolve?

Blindchild02
10-22-2006, 11:14 PM
Same error:
Fatal error: Call to a member function on a non-object in /forums/includes/class_bbcode.php on line 181

using 3.5.3 really want to get this working.

barca4ever
10-23-2006, 12:18 AM
Thanks man for this great mod :)

But one thing is not accomplished :( In MEMBERINFO the BB codes are not parsed :( Any idea why !! BTW I'm using VB3.5.4

RFViet
10-23-2006, 12:05 PM
does it work with vB3.5.5 ??

Blindchild02
10-23-2006, 01:33 PM
Im having that error with 3.5.3 so not sure if it works with 3.5.5
author doesnt seem to be providing support

Blindchild02
10-24-2006, 01:28 AM
bump, need help please!

Marris
10-25-2006, 09:42 AM
Sorry, this mod has not been updated for versions beyond 3.5.3.

The key to the BBCode displaying is the Plugin in step 3:

Hook Location: member_complete

Title: Custom Rank Image in MEMBERINFO

Plugin PHP Code:

*IMPORTANT: Again, you must replace field99 with the field Name of your newly created field in three locations in the following code:

PHP Code:

if ($userinfo['field99'])
{
if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());
}
$userinfo['field99'] = $bbcode_parser->parse($userinfo['field99'],3, true);
}

You must replace field99 with the field Name of your newly created field in Three locations in the following code.

I'm not sure if or how this code was changed in later versions. Have a look at the newer class_bbcode.php parser and see if there are any clues.

Another solution might be to search for a different "BBCode in Custom Profile Fields" mod that is compatible with 3.5.5. If you find one, then you can substitute that code for the plugin in step 3.

Blindchild02
10-25-2006, 11:24 AM
Im using 3.5.3 and i still get the error :|


Fatal error: Call to a member function on a non-object in includes/class_bbcode.php on line 181

Marris
10-26-2006, 06:52 AM
Im using 3.5.3 and i still get the error :|

Sorry, I looked at class_bbcode.php line 181, but I can't even guess at what's causing that error. It's possible that you have another plugin or mod that is conflicting.

You might try looking at what trackpads did here:

https://vborg.vbsupport.ru/showthread.php?p=875866#post875866

As I explained in the install intructions, the BBCode parsing code was written by another user (The Geek) and his original post seems to have been moved or removed from the vb.org forum. I'm not sure of all the ins and outs of how it works or why it's spitting out errors.

Maybe you could try asking why you're getting this error in the general Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15) forum.