Skip to:

Fetch different avatar

  • ysiggen


    So I am using bbpress alongside buddypress. This is great because running a little gaming community, it is awesome having the ability to use the widely know traditional forums as bbpress offers them while adding some great social features brought by buddypress.

    Now I’ve done my research and figured out that bbpress relies on the wp profile informations (since well wp and bbpress work great together). Aside of that, there is some synchronisation between buddypress and wp profile informations.

    What I’d like is be able to use only one avatar for both plugins. bbpress fetches the wp profile avatar while buddypress as one on its own. So my idea is to fetch buddypress’s image when displaying the user’s avatar on the forums.

    I tried to search for documentation on this and didn’t find much. I ended up digging the plugin code and stumbled upon, while looking in the /plugins/bbpress/includes/users/template.php file, bbp_current_user_avatar() which uses bbp_get_current_user_avatar() that calls get_avatar() with the desired size and user id.

    So I guess the obvious step is telling bbpress to look for the buddypress profile image rather than use this get_avatar() function, which I suspect is fetching the wp profile image.

    But I am stuck here, mainly because I am new to wordpress, also to php. I should be able to sort myself out with some indications (how and what to use) or even some pseudo code.

    I want to do this because I want people to not use their wp profile (there is not much there anyway) and rather go through their buddypress profile only.

    Thank’s in advance for any help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • This sounds like bbPress should switch to BP’s avatars just as it switches to BP’s member profiles (rather than bbPress’ profiles) if the BP profile component is enabled.

    Anyone know of a plugin that does this?

    It sounds like bbPress should probably do this out of the box



    Now that you state the obvious I didn’t even think of looking around that. Yes, BP’s profile gets displayed when someone clicks on a member while browsing the bbpress forums.

    The thing is, I guess, that the wp profile image stays the default and “true” one. Ideally, either wp should sync its avatar with BP or the other way around (BP fetches wp avatar and uses that one).

    Now as I’d like to keep it as it’s built, since it is quite good looking already, I mean I’d like to fully use the BP profile (that bbpress redirects to, as you pointed out), I’m not too sure of what would be the fastest or/and easiest:

    • Do the wp profile images gets synced with the BP profile image (since it has one on its own)
    • Tell bbpress to go fetch the BP profile image, since my users only have access to their BP profile

    I looked for plugins that do either, already, I didn’t quite find my fit yet. And I was hoping someone would have done something similar or knows enough to talk me roughly through what I need to do in order to achieve what I want to do.

    Either way, if anyone has some clue, that would be nice.

    If there is no luck at it, I guess I’ll be trying to do it by myself, but as I am no php expert and don’t really know much about either wp, bbpress or BP, I’ll have to get going with more reading first.

    Thank’s for your reply Setphen, it lit a bulb on my side.



    Okay so I am coming back here as I resolved it (it was quite easy actually, I am just very new to wordpress and also php programming).

    I just had to use the bp_core_fetch_avatar() function instead of the get_avatar() one.
    So, I had to call the correct function at the correct location and that’s all. Here is what I put in my function.php :

    //Make bbpress use the buddypress avatar instead of the wp one
    function bbp_get_bp_reply_author_avatar( $reply_id = 0, $size = 40 ) {
                    $reply_id = bbp_get_reply_id( $reply_id );
                    if ( !empty( $reply_id ) ) {
                            // Check for anonymous user
                            if ( !bbp_is_reply_anonymous( $reply_id ) ) {
                                    //Below is the old line
                                    //$author_avatar = get_avatar( bbp_get_reply_author_id( $reply_id ), $size );
                                    //Below is the new line
                                    $author_avatar = bp_core_fetch_avatar( array( 'item_id' => bbp_get_reply_author_id( $reply_id) ) );
                            } else {
                                   // $author_avatar = get_avatar( get_post_meta( $reply_id, '_bbp_anonymous_email', true ), $size );
                                    $author_avatar = bp_core_fetch_avatar( array( 'item_id' => get_post_meta( $reply_id, '_bbp_anonymous_email') ) );
                    } else {
                            $author_avatar = '';
                    return $author_avatar;
    add_filter('bbp_get_reply_author_avatar', 'bbp_get_bp_reply_author_avatar');



    Too late to edit my reply, I’d like to point out the fact that I was looking in the wrong area for replacing the wp avatar (with the bp one) as obviously in a forum, the avatar of each reply is attached to the… reply!

    That way I added a filter on the bbp_get_reply_author_avatar method instead of the bbp_get_current_user_avatar one.

    Personally, I’m not done as I am going to track down every part of my website where the wrong avatar gets displayed (which obviously means going through the wordpress code), but that’s not a bbpress concern anymore.

    (I don’t know if there is like a “resolved” mark to give or something, but I’m all done with this topic 🙂 )



    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!



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

    Robin W


    great – thanks for adding

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