Skip to:
Content
Pages
Categories
Search
Top
Bottom

Using Buddypress avatar

  • @jbrandsma

    Participant

    I am using bbpress in conjunction with buddypress and I noticed that the forums have different avatars for users than their profile avatar. Is there a way to use the avatars from buddypress and not from bbpress?

    I found this topic and its exactly what I’m referring too, but it was never marked as resolved and the answer was only for replies. The code snippet in this post works for me, but I need it to go further and apply to all avatars. I tried adding a filter to ‘bbp_get_current_user_avatar’ but I can’t get it to work.

    Wordpress, buddypress, and bbpress are all up-to-date – I also have the Youzer plugin installed

    Thanks in advance!

Viewing 10 replies - 1 through 10 (of 10 total)
  • @jbrandsma

    Participant

    Welp.. I figured it out. Here is the code that I placed in my theme’s function.php file so that all avatars are rendered correctly:

    function jb_get_bp_user_avatar($avatar, $id_or_email, $size, $default, $alt)
    {
        if (is_numeric($id_or_email)) {
            $id = (int) $id_or_email;
            $user = get_user_by('id', $id);
        } elseif (is_object($id_or_email)) {
            if (!empty($id_or_email->user_id)) {
                $id = (int) $id_or_email->user_id;
                $user = get_user_by('id', $id);
            }
        } else {
            $user = get_user_by('email', $id_or_email);
        }
        if ($user && is_object($user)) {
            $avatar = bp_core_fetch_avatar(array('item_id' => $user->ID));
        }
        return $avatar;
    }
    add_filter('get_avatar', 'jb_get_bp_user_avatar', 10000, 5);

    @robin-w

    Moderator

    great – thanks for posting the solution

    @vinoj

    Participant

    Hey this doesn’t seems to work for me.
    Currently I am using following plugins.
    * bbPress
    * BuddyPress
    * Ultimate Member

    For all bbPress widgets and shortcode I am unable to force BuddyPress user profile pic.
    Can anyone please guide me what am I missing?

    @vinoj

    Participant

    Hi,
    Any update on this…
    Thanks

    @vinoj

    Participant

    Hi @robin-w
    Any comments from you would be really helpfull.
    Thanks

    @robin-w

    Moderator

    so it works except widgets and shortcode? (and which shortcode?)

    @vinoj

    Participant

    I have just found that it works perfectly if I disable Ultimate Member Plugin.
    I don’t even require above code and all the user profile pics seems to be working properly.

    @robin-w

    Moderator

    great – glad you are fixed !!

    @vinoj

    Participant

    Thank you @robin-w

    @vinoj

    Participant

    Hi
    I have received solution from UM support.
    If you want to use UM plugin with bbPress & BuddyPress you just have to remove filter to disable UM avatar
    Checkout this link for more details.
    https://wordpress.org/support/topic/buddypress-bbpress-widget-shows-different-profile-pics-with-um-plugin/

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Skip to toolbar