Search code examples
wordpressbuddypress

get_avatar alternative for Buddypress's uploaded photo


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?


Solution

  • 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.