MyBB Community Forums

Full Version: Assign default avatar to current users without one and new users?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello there,

I'm trying to display the user's avatar on the index page after logging in (which I figured out).

<img src="{$mybb->user['avatar']}" alt="Avatar" title="My Avatar">

However I noticed I get a red 'X' when the user does not have an avatar.

Is there a way to assign a default avatar to existing and new users?

I'm guessing it involves using some SQL queries and/or 'if....else' statement.

Please excuse me if I'm asking too much. Undecided
You can for new users with DennisTT's Default Profile plugin.
Thank you, I can't believe I missed that plugin.

As for the existing users, if anyone is curious I ran this SQL query:

UPDATE `mybb_users` 
SET avatar = "./images/default_avatar.gif"
WHERE avatar = ""
Smile It is very useful.

Interesting, I'll make a note of that.
You could also modify mySQL to include a default value, so that on registration, mySQL automatically assigns a "blank" avatar...

Rolleyes
I'm still not too savvy with MySQL but it's getting there Toungue
(2008-10-27, 10:07 PM)Matt_ Wrote: [ -> ]I'm still not too savvy with MySQL but it's getting there Toungue

Dead easy Toungue In PHPMyAdmin. open (tableprefix)_users, and click on the select boxes for avatar and avatardimensions. Edit these two fields - one of the settings will be "default". Just set the one in avatar to images/example.jpg and the one in avatardimensions to 90x90, or whatever the dimensions are Smile
oh yea, that does make sense. Thanks for that bit of info. Smile