View Full Version : Random Rotating Avatar for specific users
Michael Morris
09-07-2005, 10:00 PM
This little plug in allows you to have a random avatar instead of a constant one. The avatar of the user(s) you do this to will change each time their postbit is called. This will allow you as an admin, and those you choose (usually mods) to stand out a little more. Be cautious on using this too liberally unless you theme the avatars (all by the same artist - all of the same character, etc.).
Start out of course by creating the images that you want to cycle through and place them in the same directory, numbering them sequenctially -- 1.jpg, 2.jpg, 3.jpg, 4.jpg etc.
Now go to the plug in manager and click "Add New Plug in." Name it "John Doe's avatar" or some such. The hook location is "postbit_display_complete"
The code is as follows:
if ($this->post['userid'] == Y)
{
$randomavatar = rand(1,X);
$this->post['avatarurl'] = "http://yourdomain/path_to_your_directory/$randomavatar.jpg";
}
X is the upper most picture you made - so if your highest picture is 22.jpg you would use rand(1,22)
Y is your user id (or the id of the user you want this to apply to.
If you want to do this to multiple users then put multiple instances of this code in the same plugin to save on queries.
Make sure to keep your avatar set to something despite this plug in -- if you don't vbulletin will think there is no avatar and set the $show['avatar'] variable to false. While you could override this you'd need to check the logged in user's preferences to see if they even want to see avatars. It's just a whole lot easier to avoid the issue by making sure that vbulletin has an avatar on file for the user this plugin affects - this plugin will then switch the avatar url after vbulletin has made all it's normal determinations.
Tested on RC2, should work on all versions.
TCattitude
09-08-2005, 06:01 PM
<a href="https://vborg.vbsupport.ru/showthread.php?t=83252" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=83252</a>
good idea but this has potential to get really messy.
good starting point though.
Cyricx
09-08-2005, 07:53 PM
Hmm couldn't you make it a lil less messy though?
Add a new user field "randomavatar" with the yes/no code
and a new user field of "maxrandavatar"
if ($this->post['randomavatar'] == 1) // meaning yes
{
$randomavatar = rand(1,$post['maxrandavatar']);
$this->post['avatarurl'] = "http://yourdomain/forumdirectory/images/avatars/random/$post['userid']/$randomavatar.jpg";
}
Then you'd create a new folder in the avatars folder called "random" and then add new folders of that users userid with the avatars in there.
Course you'd go through the admin users panel to turn it on and set how many images it randomizes through.
That's my input :)
Awesome idea though, will definately be implementing this in some form for premium members :)
Michael Morris
09-09-2005, 01:40 AM
https://vborg.vbsupport.ru/showthread.php?t=83252
There is no zip file because this hack needs to be partially rewritten before being deployed. I suppose a complicated interface for the admincp could be written to avoid this need, but I don't have the time to do it.
And BTW - if the mods and admins need your help, I'm sure they'll let you know.
Boofo
09-09-2005, 01:48 AM
You migth want to make the plug-in for this as it would be considered a code mod without, it wouldn't it?
Michael Morris
09-09-2005, 01:52 AM
You migth want to make the plug-in for this as it would be considered a code mod without, it wouldn't it?
I'm not sure - you don't need to upload anything. You just need to edit the phpcode in the first post, go to the admincp and click "Add new plug in", and paste the code in the code field.
I could make an xml file, but that only adds an extra step since the user will still have to edit the plug in and provide the path to the images directory where the random images are, the maximum rand seed and the userid that it is to affect before it will work correctly.
Boofo
09-09-2005, 01:58 AM
A simple admin CP setting would take care of that.
Thomas Heretic
09-09-2005, 01:05 PM
Nice mod. I use one slightly different that doesn't require naming of the files in any specific method, but yours will run faster.
Wordplay
09-10-2005, 09:24 PM
anybody got a hack coming out with random avatars for all users within specific usergroups?
thought that would be cool, if all users had 1-5 rotating avatars. number of rotating avatars set by usergroup options.
Michael Morris
09-25-2005, 11:36 PM
anybody got a hack coming out with random avatars for all users within specific usergroups?
thought that would be cool, if all users had 1-5 rotating avatars. number of rotating avatars set by usergroup options.
No, but this hack would definitely be a good starting point to develop such an expansion - and anyone who wants to do so has my blessing to go ahead and publish it here.
Bubble #5
10-05-2005, 04:22 AM
anybody got a hack coming out with random avatars for all users within specific usergroups?
This would be a nice add-on for members who donate.
LadyBeth
10-09-2005, 02:10 PM
If this could be set for a user who gets to a certain "rank" I would love it.
Beth
piXelatedEmpire
10-12-2005, 09:55 AM
Is anyone currently working on this hack? I would love to see a admincp option developed for this.. and the ability to apply this to certain usergroups
Next-Selection
10-14-2005, 01:34 PM
Is anyone currently working on this hack? I would love to see a admincp option developed for this.. and the ability to apply this to certain usergroups
WORD !!!
Gaffer
10-14-2005, 11:51 PM
Cool... someone made another one of these...
i made something like this for Verseion 2.2.x but i've never been able to convert it, mainly cause i've not had the time
https://vborg.vbsupport.ru/showthread.php?t=44749
tony adams
06-11-2006, 10:23 PM
excellent hack, been after this for a long time
gakousei
10-12-2007, 07:06 AM
Tested but it doesn't work on v3.6.8.
Nobody cares about this kind of mod ? I want to have this function on my forum.
Ragnarok
11-12-2007, 08:02 AM
Works fine on my v3.6.8 install.
It possible to change it to work on the memberlist and in profiles as well, and any other add-ons?
As installed you only get random avatars in the postbits, and your usercp-set avatar displays everywhere else.
BigDog56
07-05-2008, 10:56 AM
I just tried this in 3.7.2 and it works just fine! thank you!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.