[Plugin: Add Local Avatar] Fix for problem with uploading avatar images
-
Like a lot of people here, I couldn’t get this plugin to successfully upload and display local avatar images. After looking back through the comments of other people posting the same complaint and following some other links, I found this solution by baldgoat. It requires changing code in the PHP file, which could be scary for people who have no idea what they’re doing, so I have included step-by-step instructions on what to do.
1) Deactivate the plugin.
2) Click on the Edit link for the plugin. The file you want to edit is avatar.php.
3) Find the following line of code:
return substr(ABSPATH, 0, -strlen(strrchr(substr(ABSPATH, 0, -1), ‘/’)) – 1);
4) Comment it out by adding // in front of it. This is so that you can undo the changes if you need to.
5) Below that line insert this line:
return ABSPATH;
6) Find the following code (under the comment “Try to use local avatar.”):
if($id) {
$local = get_usermeta($id, ‘avatar’);
if(!empty($local)) {
$src = $local;
$avatar_type = TYPE_LOCAL;
}
}7) Replace it with:
if($id) {
$local = get_usermeta($id, ‘avatar’);
if (!empty ($local)) {
$local = get_bloginfo(‘url’).$local;
}
if(!empty($local)) {
$src = $local;
$avatar_type = TYPE_LOCAL;
}
}8) Click on Update File.
9) Reactivate the plugin and go to its admin screen.
10) In the User Uploads section, you should notice that, if your WordPress site is in a subdirectory, the subdirectory name is now showing in the directory address that follows “If allowed, use this directory for user avatar uploads, e.g. /avatars. Must have write access and is relative to…” You might have to hit Reload/Refresh first to see it.
11) Make sure that “Or, use legacy (v7.3 and lower) $_SERVER[‘DOCUMENT_ROOT’] method” is NOT checked and that the User Uploads checkbox is checked.
12) Enter the location of the folder where you want the avatar files to be put (mine is /wp-content/uploads/avatars/).
13) If you haven’t already done so, make sure that the permissions of the avatars folder is set to 755 so that it can be written to. (Note: Some hosts may require that you set the permissions to 777.)
Now go to your profile and upload a new avatar so you can test it out. After doing these things, the plugin works fine for me in 3.3.2. Hopefully, it will work for you as well.
- The topic ‘[Plugin: Add Local Avatar] Fix for problem with uploading avatar images’ is closed to new replies.