PDA

View Full Version : Custom Rank System


viper2k6
08-03-2006, 11:56 PM
I'm trying on working on having a custom user avatar underneath the regular vbulletin avatar. The custom avatar is retrieved with a dynamic php script (getavatar.php?account=1) which is associated with each users forum id.

I was wondering what is the best way to insert this into the postbit template for each user. I know I can get the user id using $post[userid], I'm just now sure on how to include it. Any help is appreciated.

pyro.699
08-04-2006, 12:03 AM
id use plugins. and just put your code in the plugin.

hooklocation: postbit_complete

or something like that.

(if you like having a file try...)

require_once('./some/dir/file.ext');

viper2k6
08-04-2006, 12:10 AM
so some like:

ob_start();
include('./getavatar.php?account=$post[userid]');
$getavatar = ob_get_contents();
ob_end_clean();

The only question is what's the correct reference to get (call) the poster's userid in a plugin.

pyro.699
08-04-2006, 12:39 AM
oh :)

ok, since this will be used many times (once per post), use

global $db;
global $vbulletin;
//im not sure if these are required, i include them in all my plugins though
$postersUserid = $post['userid'];

viper2k6
08-04-2006, 01:08 AM
I tried it in a plugin and it just spit out all of the php imaging code (weird characters, etc):

ÿÛ¸Ù&D•PÃ"¸sÃ0¶eÓÛc|¢~Sô¬¡˜SnÒÐÒx‰^:œÊ¸n” ϙå‚BŒ¥]N<µë*ûúW~ç5Q@Q@Q@Q@Q@€<45½\]Ý'ú£lô‘û/øû}kÜmȽf'þ=ã8Ç÷y'D²Ó`P'“€ï# W K;Híã<"ã=ϽgV|ˆÒœ9™=ÅÈAÚ±îo9ç‘éPÜÝõæ ±înúó^eJÇ|)–ój3J¢å

I tested the image in a post doing getavatar.php?account=1 which display fine. But if I try using a <img src="getavatar.php?account=$post[userid]"> in the postbit template, it doesn't allow it. Is there a setting to allow dynamic php images (files ending in ? or &) within a template?

If use the <img src="getavatar.php?account=$post[userid]"> and view the source code, it correctly lists the <img src="getavatar.php?account=1">, but it doesn't display the image.

peterska2
08-04-2006, 01:25 AM
are your avatars and attachments stored as files or in the database?

viper2k6
08-04-2006, 01:29 AM
They are stored as files and are assigned in a seperate database/table:

userid | avatarurl

I use the userid as a reference between the vbulletin user table and my customavatar database. I then create a php script which retrieves the userid and display the appropriate image:

Example: If I use <img src="getavatar.php?account=1"> in a standard php document, it displays it perfectly.

The problem comes as I stated in the previous post. Correctly shown in the source code, but not displayed.

peterska2
08-04-2006, 01:35 AM
ah, In the vBOptions > Message Posting and Editing Options > Allow Dynamic URL for [IMG] Tags

Try setting that to YES and see if it makes any difference

viper2k6
08-04-2006, 01:42 AM
ah, In the vBOptions > Message Posting and Editing Options > Allow Dynamic URL for [IMG] Tags

I did enable that option, and if I try getavatar.php?account=1 in a post the image shows up perfect...however the <img src="getavatar.php?account=1"> in the postbit template, doesn't display an image at all - but upon viewing the source code, it's referenced correct.

pyro.699
08-04-2006, 09:58 AM
hrm, that sounds prety odd. and makes little sence. because if [img] works, then so should <img>.i would just check to make sure everything is spelled right. if it still dosent work. View the source when you use [img] and compare it with <img>. Hope this helps

~Cody Woolaver

viper2k6
08-04-2006, 04:08 PM
Cool, now it seems to work perfectly. My next question is as far as optimization, is it more efficient to point to a dynamic php image file or would it be better to have a plugin with a query to retrieve the image url instead ... thanks for all of the quick responses!

Grasty
08-14-2006, 07:24 PM
This may not be what your looking for but i am an admin on oxy-moron.net. And what we did for ranks was we used the user ranks option in the Admin CP, along with the Promotions option to facilitate that.

Basically you have a usergroup for each rank you want, the images are stored on the server. Then you go to the User Ranks Menu on the left hand side. Choose Add new rank, Choose the usergroup your applying it to, If your having multiple different ranks on one user choose Yes for Stack Rank, if that is their only rank choose No. Put in the path to the image and click submit.

Then to assign someone a new rank you can just go into their ser account and change their usergroup, their image will automatically change no coding needed.

I also came up with a way of using the Promotions option to automatically advance someone from a registered user to whatever the lowest rank is. Our system originally was using a Army Rank structure, and all new registered people were Recruits. So the User Promotions option allowed us to automatically advance someone to recruit without having to change the usergroup on every new member