Skip to:

Opened 14 years ago

Closed 14 years ago

#2046 closed defect (bug) (duplicate)

Only admin avatar in comments at blog #1

Reported by: mmeida's profile mmeida Owned by:
Milestone: 1.5 Priority: major
Severity: Version:
Component: Core Keywords:


When BP is not installed in WPMU blog #1, the comments in blog #1 show the admin avatar instead users avatars at the public site, not at the control panel or BP itself.

Deactiving BP resolves the problem.

WPMU 2.9.1 / BP 1.2

Change History (5)

#1 @mmeida
14 years ago

  • Milestone changed from 1.2.1 to Future Release

#2 @apeatling
14 years ago

  • Milestone changed from Future Release to 1.2.1

#3 @apeatling
14 years ago

  • Milestone changed from 1.2.1 to 1.2.2

#4 @lgedeon
14 years ago

  • Component set to Core

This can happen on any blog not using a BP theme. BP is designed to work with other themes so the fact that is does not work qualifies as a defect, but I found a solution for one version of the problem and learned a few things along the way that might help with other BuddyPress avatar problems.

Full text at: <a href=""></a>

What I found:

In the file /wp-content/plugins/buddypress/bp-core/bp-core-avatars.php, lines 344 and following contain the following code:

global $authordata;
if ( is_object( $user ) )
$id = $user->user_id;
else if ( is_numeric( $user ) )
$id = $user;
$id = $authordata->ID;

if ( empty( $id ) )
return $avatar;

I think that last “if statement” may be there to catch cases where the commenter does not have a BuddyPress account (which is the majority on my site at this point). However, if you look closely at the block just above the “if ( empty( $id))” you will notice $id is never going to be empty at this point.

That suggests two possible solutions.

Solution 1:

I have not tested this, but it makes sense that you could move the last “if statement” above the first “if statement.” That way you can check for “empty( $id )” before it gets set to”$authordata->ID”

Solution 2:

I found it works quite well to add these lines just under the last “if statement.”

if ( is_string( $user ) )
return $avatar;

This will catch any case where an email is sent as input, which is what all (most) non-buddypress themes send. Cases where numbers or objects are sent (the BuddyPress method) will be handled normally.

I am going to spend a little more time getting familiar with BuddyPress and then try to get dev access so I can get this fix into a future release of BuddyPress. In the mean-time, we will have to just do it as a hack.

#5 @DJPaul
14 years ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #2288 (closing this instead of that because #2288 has a patch).

Note: See TracTickets for help on using tickets.