[Admin Trick] Setting a Default User Avatar 05-06-2013, 12:43 PM
#1
There are two things to do if you want to set a default user avatar.
First for the new users:
If you want to set a default avatar to all the newly registering users automatically; open:
inc/datahandlers/user.php
and find at about line no. 973 / 974:
replace with:
Now Second step is about setting the default avatar for all the avatar-less users who have been already registered. For that we have to update our database using PhpMyAdmin.
Go to your hosting cPanel and run PhpMyAdmin.
Select the database of your forum.
Run the following query ...
If you wanna reset avatar of every user regardless of they have avatar set or not then tun this:
Change the DB Prefix (mybb) as per what is set for your database.
Now upload a decent 100px x 100px avatar in your 'images' folder using FTP. If you are using different size of avatar; change the declared size at the end of the following line accordingly:
You can change the path of the avatar (as well as image format) as per your own. In that case change the path "images/avatar.png" to wherever your avatar is located.
If you are not uploading the avatar in your hosting and using external image host; then remember to change
to
First for the new users:
If you want to set a default avatar to all the newly registering users automatically; open:
inc/datahandlers/user.php
and find at about line no. 973 / 974:
PHP Code:
"avatar" => $db->escape_string($user['avatar']),
"avatartype" => $db->escape_string($user['avatartype']),
replace with:
PHP Code:
"avatar" => 'images/avatar.png',
"avatardimensions" => '100|100',
"avatartype" => 'gallery',
Now Second step is about setting the default avatar for all the avatar-less users who have been already registered. For that we have to update our database using PhpMyAdmin.
Go to your hosting cPanel and run PhpMyAdmin.
Select the database of your forum.
Run the following query ...
PHP Code:
UPDATE `mybb_users` SET `avatar` = './images/avatar.png' WHERE `avatar` = ''
If you wanna reset avatar of every user regardless of they have avatar set or not then tun this:
PHP Code:
UPDATE `mybb_users` SET `avatar` = './images/avatar.png'
Change the DB Prefix (mybb) as per what is set for your database.
Now upload a decent 100px x 100px avatar in your 'images' folder using FTP. If you are using different size of avatar; change the declared size at the end of the following line accordingly:
PHP Code:
"avatardimensions" => '100|100',
You can change the path of the avatar (as well as image format) as per your own. In that case change the path "images/avatar.png" to wherever your avatar is located.
If you are not uploading the avatar in your hosting and using external image host; then remember to change
PHP Code:
"avatartype" => 'gallery',
to
PHP Code:
"avatartype" => 'remote',

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)