Custom User Avatars For WordPress

How To Set Custom User Avatars On WordPress

If your website allows for user interaction with it (e.g., commenting or posting something otherwise), they’re most likely represented either by default placeholders instead of custom avatars or Gravatars. It can be sufficient as a temporary solution, but if you want to enhance your site’s user experience, you should add the opportunity to set custom avatars.

Why do we attach so much importance to customization?

Well, it’s not just us. Multiple studies claim that people attach notable importance to the pictures they choose for their profile. Some people may be sensitive about their default visual representation (various kinds of icons) or even be offended by the default icon; all the more reasons to add the functionality responsible for avatar uploading.

It’s a proven fact that letting your users set custom avatars humanizes the interface and personalizes everyone’s experience. However exceptional your work on the website branding was, people need to feel they’re taken into account, too. Customization is generally a good practice as it helps you stand out from the crowd. Try customizing your theme, and you’ll see how it can change things for the better! And user profiles are no exception, too.

Default options

The built-in functionality on WordPress displays user Gravatars if they’re available. Gravatars are the images linked to your email. The point is that whenever you register with this email on a website, this website uses your Gravatar as a personal profile picture. You can set yours on their website.

So, by default, if a user has a Gravatar, WordPress displays the one. If a user doesn’t, then there’s a placeholder icon called Mystery Person – WordPress will use that one.

How To Set Custom User Avatars On WordPress

WordPress doesn’t leave you with no choice, though. Under Settings > Discussion on your dashboard, you’ll find the following options:

How To Set Custom User Avatars On WordPress

Even though those are more customized than the Mystery Person, the default options are not personalized in the way users may want. As you see, there’s no upload functionality; same as you don’t get to set your custom avatar when registering on WordPress.org, users won’t be able to select theirs if you don’t add this functionality.

That’s why, when it comes to letting your users select their avatars themselves, things are not as easy as you may imagine. WordPress doesn’t provide the upload option, which is something we want to fix.

Adding custom avatar functionality

A possible solution would be to write the code for the functionality at the stage of creating the site. It implies creating an upload field and adding the necessary hooks to know when to return which image. It may be a decent practice of your coding skills if that’s what you’re aiming for. But you don’t have to come up with it on your own; there are several other things you can do.

Adding code to functions.php

If you want to have a custom avatar, you can upload a file to your Media Gallery and then call it in your functions.php file.

Be careful! Mistakes in editing your functions.php file can lead to code formatting errors that, in their turn, can result in an RSS feed error.

What you need to do is:

  • Go to Media > Add New on your WordPress dashboard;
  • Upload the image of your choice;
  • Click Edit next to the image you’ve uploaded:
How To Set Custom User Avatars On WordPress
  • Copy the image URL in the File URL field;
  • Paste the following code snippet in your functions.php:
add_filter( 'avatar_defaults', 'wpb_new_gravatar' );
function wpb_new_gravatar ($avatar_defaults) {
$myavatar = 'http://example.com/wp-content/uploads/';
$avatar_defaults[$myavatar] = "Default Gravatar";
return $avatar_defaults;
}

And change the URL in line 3 (in red) to the one you’ve copied from the Media Gallery.

How To Set Custom User Avatars On WordPress

NB: Sometimes, theme-specific restrictions wouldn’t allow for this change. If this solution doesn’t work, you can contact your theme support to clarify the issue.

However, not everyone is comfortable going that deep into coding just for the sake of customization. It does require substantial expertise in the field or at least eagerness to learn this aspect of web development.

In essence, it would mean creating a plugin, as the snippet would work as an addition to the default functionality.

“WordPress is insanely rich with plugins! Could it be that there’s already one for this purpose?”

Great question! And yes, right you are, you can install one of the plugins that resolve this problem.

Custom avatar plugins

Avatar Manager

When you install this plugin, you get a new option in Settings > Discussion on your dashboard that reads Anyone can upload. If you check the corresponding box, your users will be able to upload their custom images.

Users self-host their custom images, which becomes especially valuable when there’s a lot of users on your site.

WP User Avatar

This is a simple and lightweight plugin. While being noticeably concise and offering not too much, it does what it’s supposed to do perfectly well. It allows selecting to display the Gravatar or the default icon as well. You can also upload your custom image and change the default icon in the Users > Profile section on the dashboard.

How To Set Custom User Avatars On WordPress

WP First Letter Avatar

There’s yet another thing you can do if you don’t want to add the upload functionality to your WordPress site but do want to use custom avatars. This plugin sets initial letters as a placeholder, which works well enough, too. It may not be as personal as a profile image, but it’s considered better than a plain icon.

How To Set Custom User Avatars On WordPress

There are more custom avatar plugins you can find on WordPress. Maybe you’ll find a different one that answers your needs in user profile customization; share your favorite solutions!

Comments

Leave a Reply

(Your email address will not be published)