[FILLED] Random Avatars

leonpadi

New Member
Greetings guys!
I would like to express u one thought i had today.
Imagine a vb forum, with 100 avatars available for users to select from.

What if we (as admins) could have a hack-mod which could daily change people's avatars (even better per usergroup, so specific usergroups could have avatars from a specific category for example).

Well :) This hack is available here...
Random Rotating Avatar for specific users - vBulletin.org Forum

Is this hard to upload it please ? :)
 
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:


PHP Code:
Code:
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.

***

This is all :) nothing uploaded
 
Back
Top