• Resolved tdechangy

    (@tdechangy)


    I was setting up a social login plugin (Super Socializer) which allows to load the Social avatars by the way. I did it in the obvious reason to display it with User Menus. Sadly i had to realize that the user avatar was not displayed.

    Hopefully I found this useful topic which solved my question in no time.
    https://www.ads-software.com/support/topic/avatar-doesnt-display-on-nav-menu/

    I guess that you should consider changing the code accordingly to the suggestion.
    It seem to work for social logins as well as Gravatar images. For some reason the CSS didn’t apply anymore…

    Here was the solution :

    In the plugins/user-menus/includes/classes/menu/items.php file, just locate those lines danieliser pointed out:

    case 'avatar':
    $replace = get_avatar( $current_user, self::$current_item->avatar_size );
    break;

    and replace them for:

    case 'avatar':
    $replace = get_avatar( $current_user->user_email, 32 );
    break;

    This worked for me, using ProfileGrid, and this is very similar to the answer provided by user mattyshigh here, but it differs from the way the user ID is pulled from to get the avatar.
    Thank you mattyshigh for inspiring me the answer, and danieliser for this awesome plugin and his readiness to help. Cheers to the forum!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Daniel Iser

    (@danieliser)

    @tdechangy Thanks, will get a patch out shortly. Not sure how that got by and worked for so many. I looked and get_avatar accepts an $id_or_email parameter, a WP_User object should never have worked, but I can confirm it still does lol.

    In any case I’m gonna likely go with $current_user->ID, can you confirm that works for you still.

    Thread Starter tdechangy

    (@tdechangy)

    $current_user->ID seem to work fine to and definitely a safer choice I guess. Adding , 32 can be good to specify the default icon size, but I leave you the choice on that.
    I’ll now use the ID with some CSS to ensure compatibility whatever choice you make.

    Plugin Author Daniel Iser

    (@danieliser)

    @tdechangy – Thanks for confirmation.

    The avatar size is customizable in the nav menu editor already, why pass a hard size in?

    self::$current_item->avatar_size refers to the current menu items chosen avatar size.

    Note also that even if no custom value is entered, it has a default of 24px already (wp-content/plugins/user-menus/includes/classes/menu/item.php:32).

    • This reply was modified 5 years, 10 months ago by Daniel Iser. Reason: added final note on defaults
    Thread Starter tdechangy

    (@tdechangy)

    That’s right, I forgot this point. But when using the code with ID it seem that the icon size was not related to that code anymore.
    Maybe a bug on my side but I let you check this since PHP is not much my domain.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Updating Avatar for multiple sources’ is closed to new replies.