Customize wp user avatar plugin depending on the user roles

Wp user avatar
Wp user avatar

Wordpress has around 36000+ plugins in the repository, one can almost every time can find at-least a plugin for anything and everything around WordPress. In a recent project, I was needed a functionality where the users can upload their image and use it instead of one from Gravatar

Looking for a solution to the above requirement, I came across the plugin WP User Avatar, this plugin is exactly what I wanted except few changes. This plugin allows all user roles above Author to upload an image as an avatar to the profile. This plugin also has a setting to include the contributors and subscriber to avail this facility.

With the above, I need to make few changes, firstly I had to include contributors into this fold to allow upload images for the profile and not the subscribers and lately the requirement changed a bit to allow the functionality only for all the users with roles administrators and contributors and hence excluding all other roles.

Looking deep into the codes of the plugin, I came across the filter which would do the trick along with current user can function.

Following can be added to the theme’s or most appropriately I would say child theme‘s functions.php file to include only the contributors and not subscribers to the allow uploading images as their avatar

Now add the following to allow all the users under roles contributors and administrators to have this feature and exclude others.

You can add the other set of roles to the condition to make this available for the respective user roles.


Maruti Mohanty

I am a happy go lucky WordPress Developer, who loves biking, movies and learning different languages


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: