Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get the current avatar for logged in user in WordPress
<?php
// Ensure user is logged in
if( is_user_logged_in() ) {
// Display current logged in user's avatar (includes <img> tag)
echo get_avatar( get_current_user_id(), 96 );
// Display current logged in user's avatar URL
echo get_avatar_url( get_current_user_id(), array( 'size' => 96 ) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment