Print User Avatar from User ID in Buddypress

So, I have a user ID in Buddypress.

What is the print function of your avatar?

What is the function of linking to their profile?

+8
buddypress
source share
5 answers

This will display the user avatar by user ID, and also make the avatar a clickable link to their profile.

<?php $member_id = bp_core_get_userid( '1' ) ?> <a href="<?php echo bp_core_get_user_domain( $member_id ) ?>" title="<?php echo bp_core_get_user_displayname( $member ) ?>"> <?php echo bp_core_fetch_avatar ( array( 'item_id' => $member_id, 'type' => 'full' ) ) ?></a> 

Obviously, replace the number in the first line with the desired user ID.

+14
source share

You can simply use the bp_activity_avatar() function:

 <?php bp_activity_avatar(array('user_id' => $user_id)); ?> 
+1
source share

Display user avatar for the specified user ID

  bp_activity_avatar( 'user_id=' . $user_id ); 

Returns an HTML link for a user with a fully qualified user name as the link text for the specified user ID

  echo bp_core_get_userlink( $user_id ); 
+1
source share

I managed to do this with the following code (without php warnings):

 $imgTagAva = apply_filters( 'bp_group_request_user_avatar_thumb', bp_core_fetch_avatar( array( 'item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_core_get_user_displayname( $user_id ) ) ) ) ); 
0
source share

found him. The best solution below:

 get_avatar(get_the_author_meta('ID'), 40); // OR get_avatar($author_id_or_email, $size); 
-one
source share

All Articles