php - Displaying avatar image in img src Wordpress -


i want display logged in user avatar in img src="". worked in wordpress , used code display no results.

<img src="<?php global $userdata; get_currentuserinfo(); echo get_avatar( $userdata->id, 46 ); ?>" 

per documentation, in combination get_avatar method (46 size): http://codex.wordpress.org/function_reference/get_currentuserinfo

the function assigns value $current_user, not $userdata. here updated code

<?php         global $current_user;         get_currentuserinfo();         echo get_avatar( $current_user->id, 46 );  ?> 

but i'd add can skip using method get_current_user_id: http://codex.wordpress.org/function_reference/get_current_user_id

<?php     echo get_avatar( get_current_user_id(), 46 ); ?> 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -