Thanks.
I will check the issue with user-avatar and return with my conclusion this week.
User Avatar plugin shows user avatar in user profile in 2 cases:
1) current user is profile owner
2) user is super admin for this blog.
if(($profile->ID == $current_user->ID || is_super_admin($current_user->ID))) {
is_super_admin() function in wp-includes/capabilities.php checks if user is super-admin for network in case of multi-site installation or if user has ‘delete_users’ capability for single WordPress installation.
Thus, if you work under multi-site WordPress your editor should be super-admin, or add him ‘delete_users’ capability for stand-alone WordPress configuration.
tpflanz and Vladimir,
Thanks for this post, it made finding the code I needed to edit extremely easy. I am running a multisite installation that I need non-super admin users to be able to edit users on one specific site. To achieve this I have granted them edit_users capability via the User Role Editor as well as some hackery elsewhere.
Why doesn’t User Avatar allow users with edit_user privileges the ability to change other users avatars? It’s easy to code.
Instead of this in user-avatar.php:
if(($profile->ID == $current_user->ID || is_super_admin($current_user->ID)))
I changed it to this:
if(($profile->ID == $current_user->ID || ! current_user_can(‘edit_user’, $current_user) || is_super_admin($current_user->ID)))
Now I know this is not recommended because it’ll break on the next update but I need the feature. Can either of you think of a better way to do this than granting the users Super Admin rights?
lifelikeneek,
In User Role Editor, you simply need to give the Editor delete_users capability so they can change the avatar for each user.
Note: This will also allow editors to be able to delete a user, but most likely, that would not be an issue.
@lifelikeneek…..
I had to fix your code to get it to work. Should be this….
if(($profile->ID == $current_user->ID || current_user_can('edit_user', $current_user->ID) || is_super_admin($current_user->ID)))
Now works as it should. You had an exclamation point, which made all users who CAN edit users, NOT be able to upload avatars.
Um… As pointed out above, you do NOT need to edit code at all.
You simply need to use User Role Editor and give your editor class delete_users
capabilities
@greekdish,
Sorry for the delayed response. Thanks for pointing that out. I’ve fixed it in my code. What is interesting is that it was working with the ! in there. I will have to debug to find out why.
@tpflanz,
I appreciate that but that does not seem to work with Multisite. Also I want to avoid granting these users the delete_users capability, they are still intended to be lower level users even though they need edit_user privileges. They are not supposed to be able adjust any settings, pages, or posts.
Thanks for the update! Nice work!