Quantcast
Channel: BuddyPress.org » All Posts
Viewing all articles
Browse latest Browse all 321

Reply To: How do I display a single user’s avatar with just the username NOT user-id?

$
0
0

Try this for your avatar display.

Your shortcode syntax would look like …

[showavatar username=”johnsmith”]

You can change width & height to your preference.


function show_avatar ($atts) {

$user = get_user_by( 'login' , $atts['username'] );
	
return bp_core_fetch_avatar( array(
  'item_id'	 => $user->ID,
  'width'	 => 50,
  'height'	 => 50,
  ) );
}

add_shortcode( 'showavatar' , 'show_avatar' );


Viewing all articles
Browse latest Browse all 321

Trending Articles