Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Fetch different avatar

@ysiggen

Participant

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');
Skip to toolbar