Reputation: 445
I am using the following snippet in my theme to get the logged-in user's avatar of the default wp user's setting page.
<?php echo get_avatar($id_or_email, $size='64', $default, $alt='User name' ); ?>
However, After installing the buddypress; I wanted to display the uploaded profile's photo of the user where the above snippet only shows the default wp avatar.
Any idea on how to achieve that?
Upvotes: 0
Views: 455
Reputation: 1956
Use the BuddyPress function bp_core_fetch_avatar
$user_id = bp_loggedin_user_id();
echo bp_core_fetch_avatar( array( 'item_id' => $user_id) );
Review the function in bp-core/bp-core-avatars.php
to see the available arguments.
Upvotes: 0
Reputation: 179
You should enable both options:
<?php
if ( empty ( bp_loggedin_user_id() == false ) ) {
$user_id = bp_loggedin_user_id();
echo bp_core_fetch_avatar( array( 'item_id' => $user_id) );
} else {
echo get_avatar($id_or_email, $size='64', $default, $alt='User name' );
}
?>
Upvotes: 1