Re: How to add user avatar to activity excerpts
@Michael Berra
This is my implementation that should work for you. It only requires one line of core hacking.
in bp-activity-classes.php add the line as described by Jotem:
$activities_formatted[$i]['user_id'] = $activities[$i]->user_id;
Then create this new function in your bp-custom.php. If you don’t have that file, you can create it in your plugins folder and it will be automatically loaded by bp.
// **** Avatar support for activity stream ****
function bp_activity_avatar() {
echo bp_get_activity_avatar();
}
function bp_get_activity_avatar() {
global $activities_template;
$activity_avatar = bp_core_get_avatar( $activities_template->activity->user_id, 1 );
return apply_filters( 'bp_get_activity_avatar', $activity_avatar );
}
Now you can use this function in your template tags which will diplay the acting user avatar. So in your case it could look like:
...
<div class="activity-list">
<ul id="activity-list">
<?php while ( bp_activities() ) : bp_the_activity(); ?>
<li class="<?php bp_activity_css_class() ?>">
<?php bp_activity_avatar() ?>
<?php bp_activity_content() ?>
</li>
<?php endwhile; ?>
</ul>
</div>
...
The nice part of doing it this way is it leaves you some options on how to style and implement this new function.
@cozzie I haven’t looked at filtering depending on activity type, but imagine you could this as well by studying the activity class. Shouldn’t be too hard, but would be specefic function depending on your needs.