Re: Wrong Avatar and Gravatar after BP update
I found a solution for my version of the problem and learned a few things along the way that might help with you BuddyPress avatar problems.
Full text at: http://luke.gedeon.name/buddypress-wrong-avatar-fix.html
What I found:
In the file /wp-content/plugins/buddypress/bp-core/bp-core-avatars.php, lines 344 and following contain the following code:
if ( is_object( $user ) )
$id = $user->user_id;
else if ( is_numeric( $user ) )
$id = $user;
$id = $authordata->ID;
if ( empty( $id ) )
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.
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â€
I found it works quite well to add these lines just under the last â€œif statement.â€
if ( is_string( $user ) )
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.
Maybe I can get this added into the next release of BuddyPress.