jbrandsma (@jbrandsma)

Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • In reply to: Fetch different avatar

    @jbrandsma

    Participant

    For anyone who stumbles upon this, I found the solution and placed it here

    @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);
    In reply to: Fetch different avatar

    @jbrandsma

    Participant

    I hope you’re still around but I’m trying to accomplish the same goal. Your code snippet works for the replies, as you said, but I’m still trying to use the bp avatars for ALL avatars – like you. I am just curious how you handled that! Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)