Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to definitively display Buddypress avatars in BBPress???

  • I know there have been a million and one posts/questions about this. The trouble is, there is a lot of conflicting instructions… and it is scattered all over the place. I feel like I am very close, but cannot for the life of me get this to work…

    So far, I’ve successfully done the WordPress “deep integration.” I tested this by putting some random Buddypress tags in BBpress template files. They worked fine. Here’s where I’m running into some trouble:

    I am trying to display the exact same avatar that appears in Buddypress for a particular user in BBPress as well. I tested the following template tags on my profile.php (in my BBpress theme):

    bp_member_avatar(); no result (blank)
    bp_core_fetch_avatar(userid); -> no result (blank)
    bp_core_get_avatar(userid); -> function undefined
    get_avatar(userid); -> this shows the wordpress avatar, not the buddypress one

    Help. Which is the correct tag to use? I need to be able to display an avatar based on user id. That is all. Surely that’s not impossible?

    If there are no existing tags that will do this, can someone just tell me how to do a database query? I found this post http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/where-are-the-avatars/ but don’t know where to go from there…

    Thanks in advance!

    Running: WP MU 2.9.2, Buddypress 1.2.3, and BBPress 1.0.2

Viewing 25 replies - 1 through 25 (of 30 total)

  • r-a-y
    Keymaster

    @r-a-y

    I’ve seen that one. When I try that, I get:

    Fatal error: Call to undefined function bp_core_get_avatar() in /data/19/1/45/55/1860544/user/2020360/htdocs/peersforum/discuss/forum/my-templates/bbpress-peersforum/profile.php on line 4


    r-a-y
    Keymaster

    @r-a-y

    @tinabeans – just tested the following snippet:

    echo bp_core_fetch_avatar( 'item_id='.get_post_author_id() );

    This is working for me on a deep-integrated external bbPress install. Let me know if this works for you.

    YOU ARE AMAZING! You know, you just redeemed my whole afternoon of work. Hooray =) I owe you a beer for that one!

    Well… here’s the postscript. It all comes back to one thing I’ve been frustrated with: why is there no good documentation on BP or BBpress template tags? I had to search the code repo to find a hint that bp_core_get_avatar() was deprecated in favor of bp_core_fetch_avatar(), and after that still didn’t know that I had to put “item_id=” before the ID in the argument string. Not sure how I would have figured that one out on my own, given my apparent lack of PHP reading skills.

    If someone knows a secret source of well-documented template tags, do let me know. All I’ve found so far is https://codex.buddypress.org/developer-discussions/buddypress-template-tags/ for Buddypress (which doesn’t even have bp_core_fetch_avatar() listed). Bummer.

    Okay, I do have one last question for you: what other params does bp_core_fetch_avatar() take, and how can I find out? for instance, can I specify a different size of avatar?


    r-a-y
    Keymaster

    @r-a-y

    That’s because the documentation relies on users like you and me (for both bbPress and BuddyPress).

    Most of the template tags you can find in /bp-xxx-templatetags.php in the BuddyPress folder. It’s well organized enough to read and I usually just dig through the code to find what I need.

    Btw… I do take donations! You could consider that beer money ;)

    Nevermind, I googled for that function and found the SVN repo where that function is defined: http://bp-dev.org/phpxref/nav.html?_functions/index.html

    The params it takes are:

    $defaults = array(
    ‘item_id’ => false,
    ‘object’ => ‘user’, // user OR group OR blog OR custom type (if you use filters)
    ‘type’ => ‘thumb’,
    ‘avatar_dir’ => ‘avatars’,
    ‘width’ => false,
    ‘height’ => false,
    ‘class’ => ‘avatar’,
    ‘id’ => false,
    ‘alt’ => __( ‘Avatar Image’, ‘buddypress’ ),
    );

    … and the params can be fed into bp_core_fetch_avatar() in the form of “name=value&name=value” pairs as a string.

    Hope this helps someone else who is having the same issue. =)

    I actually couldn’t find the template tags php file in my buddypress folder. I think I’ll just use the SVN for now. It has a nice search function.

    Beer funds sent. Thanks again~


    r-a-y
    Keymaster

    @r-a-y

    Yup, that function can be found in /bp-core/bp-core-avatars.php

    Check out some of the other template tag functions in:

    /bp-core/bp-core-templatetags.php
    /bp-groups/bp-groups-templatetags.php
    /bp-friends/bp-friends-templatetags.php

    etc.

    Btw, thanks for the funds ;)

    @r-a-y,
    is it possible to show buddypress avatars on bbpress WITHOUT deep integration? i have a high traffic site, and i’m already low on memory!


    r-a-y
    Keymaster

    @r-a-y

    @jillsays – As long as you have your users integrated between WP and bbPress, it’s definitely possible.

    I don’t have any code to give you at the moment… but the way I’d go about it is, I’d write a function in bbPress to find your BuddyPress avatar directory, then you could do a check to see if the user_id directory exists… if so, spit out the BP avatar URL in bbPress.

    @r-a-y — any help you could give me would be tremendous. I’ve been at it for days and am about to crack!
    Writing functions is way out of my league, but if you’d be kind enough as to help, there’s beer money in it for you! :)
    Jill


    r-a-y
    Keymaster

    @r-a-y

    @jillsays – Here’s what you need to do:

    In your bbPress theme’s folder (/bb-templates/kakumei-blue), create a functions.php file and add the following:
    http://pastebin.com/PDeF3kjm (updated)

    You can adjust the default avatar in bbPress by going to the bbPress admin panel (/forum/bb-admin/) and clicking on “Settings > Discussion”.

    I’ve tried to “guess” where the BP avatar path is, however if this doesn’t work, you’ll have to adjust the $avatar_folder_dir variable manually (this will definitely apply to WPMU users).

    Give it a shot and report back.

    That’s great, @r-a-y! bbPress is now pulling in avatars for people who uploaded images through Buddypress.

    However, it is NOT pulling in images for people who only have a photo at Gravatar… and not one uploaded through Buddypress.

    Any way to tweak that?


    r-a-y
    Keymaster

    @r-a-y

    @jillsays – Did you read this:

    You can adjust the default avatar in bbPress by going to the bbPress admin panel (/forum/bb-admin/) and clicking on “Settings > Discussion”.

    @r-a-y yes, I read that. I’m not talking about the default avatar. That is showing up fine. I’m saying nothing at all is showing up for people who ONLY have an avatar uploaded via gravatar.com, like me

    Here’s the forum in question: http://foodnetworkhumor.com/forum/topic.php?id=1473&page=2

    I, and a few other users, only have a photo uploaded via gravatar, and our photos are not showing up. It’s not even displaying the default avatar.


    r-a-y
    Keymaster

    @r-a-y

    @jillsays – In bbPress’ “Settings > Discussion” page, under “Avatar Display”, did you check “Show Avatars“?

    @r-a-y yes, I did… when I uncheck that, none show up at all.


    r-a-y
    Keymaster

    @r-a-y

    @jillsays – Gravatars look like they’re working. It’s working for Blancmange, Lala and Patrina. Gravatars only work if the right email address is setup when they signed up for your site.

    If your users recently signed up with Gravatar, tell them to change their email address in BP… see if that changes anything.

    @r-a-y — the gravatar is being pulled in on my bbpress profile page, but not int the actual posts themselves. This is occurring only for people who strictly have gravatars.

    http://foodnetworkhumor.com/forum/profile.php?id=1

    (And yes, I’m using the exact same email address for wordpress, gravatar, and bbpress.)


    r-a-y
    Keymaster

    @r-a-y

    @jillsays – Thanks for that extra info!

    Replace the snippet from before with this:
    http://pastebin.com/PDeF3kjm

    This should work now!

    @r-a-y you’re a freaking genius.
    I’ll send you a little paypal love when I get to work tomorrow. Look for it then.
    Thank you man!


    r-a-y
    Keymaster

    @r-a-y

    @jillsays – Glad it worked! ;)


    Chiron
    Participant

    @chiron

    @r-a-y

    A few “?”s .
    1.) Does the functions.php need to be in the root folder for your current bbpress templates? or do you just leave it in (/bb-templates/kakumei-blue)?
    2.) Can the path to avatars folder be “http://mydomain.com/wp-content/uploads/avatars/’. $author_id;”?
    Thanks in advance


    r-a-y
    Keymaster

    @r-a-y

    @chiron

    1) Wherever your bbPress theme is, add a functions.php. eg. my-templates/MY-BB-THEME/functions.php… if you’re using Kakumei, then it would be /bb-templates/kakumei/functions.php.
    2) The path has to be an absolute filepath and not a URL. eg. /var/www/wp-content/uploads/avatars/. I’ve tried to guess where your WordPress install is using $_SERVER, but you might need to adjust this for your particular install.


    Chiron
    Participant

    @chiron

    @r-a-y

    Thanks! that answer helped me narrow down an issue I was having. To be exact, my site is on Godaddy and hosted in a subdomain(not subdirectory). In case anyone else runs into this issue, You must use $_SERVER instead of $_SERVER to get the pathing to resolve correctly.

Viewing 25 replies - 1 through 25 (of 30 total)
  • The topic ‘How to definitively display Buddypress avatars in BBPress???’ is closed to new replies.
Skip to toolbar