WordPress.org

Ready to get started?Download WordPress

Forums

User Avatar
User Avatar with User Role Editor (10 posts)

  1. Travis Pflanz
    Member
    Posted 2 years ago #

    Hi,

    Love the plugin!

    I recently added the User Role Editor plugin to allow my site's Editors to edit user profiles. However, even though I changed the Editor's edit_users capabilities, the User Avatar does not appear at all when viewing a user profile in the backend.

    Any recommendations would be appreciated. Thanks!

    http://wordpress.org/extend/plugins/user-avatar/

  2. Vladimir Garagulya
    Member
    Posted 2 years ago #

    Thanks.

    I will check the issue with user-avatar and return with my conclusion this week.

  3. Vladimir Garagulya
    Member
    Posted 2 years ago #

    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.

  4. Travis Pflanz
    Member
    Posted 2 years ago #

    Vladimir,

    Thanks. Works great.

    Travis

  5. lifelikeneek
    Member
    Posted 2 years ago #

    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?

  6. Travis Pflanz
    Member
    Posted 2 years ago #

    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.

  7. greekdish
    Member
    Posted 2 years ago #

    @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.

  8. Travis Pflanz
    Member
    Posted 2 years ago #

    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

  9. lifelikeneek
    Member
    Posted 2 years ago #

    @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.

  10. greekdish
    Member
    Posted 1 year ago #

    Thanks for the update! Nice work!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic