Skip to:

Re: How to add user avatar to activity excerpts

Jan M.


It’s not that hard to add user avatars to the activity stream, but it involves core-hacking. So as always, be warned that you won’t be able to update your BP automatically after changing core funcionality.

This takes place in bp-activity-templatetags.php

This is what your could should look like at the moment:

function bp_get_activity_content() {
global $activities_template, $allowed_tags;

if ( bp_is_home() && $activities_template->activity_type == 'personal' ) {
$content = bp_activity_content_filter( $activities_template->activity->content, $activities_template->activity->date_recorded, $activities_template->full_name );
} else {
$activities_template->activity->content = bp_activity_insert_time_since( $activities_template->activity->content, $activities_template->activity->date_recorded );
$content = $activities_template->activity->content;

return apply_filters( 'bp_get_activity_content', $content );

You’ll have to add these two lines of code at the end of the else-part

$content = bp_core_get_avatar($activities_template->activity->user_id) . $content;
return $content;

The first line adds the avatar-image, the second line returns the content.

Second line is necessary because the

return apply_filters( 'bp_get_activity_content', $content );

in the last line of the function filters out any images.

Remember: The BP-Devs had something in mind when implementing this functionality, so you may encounter security-risks…

Skip to toolbar