Skip to content

Instantly share code, notes, and snippets.

Created August 12, 2014 23:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
WordPress - custom user photo from user login name (via custom field)
$username = get_sub_field('team_member_username');
$the_user = get_user_by('login', $username);
$the_user_id = $the_user->ID;
$user_photo = get_user_meta($the_user_id, 'your_photo', true);
$image_src = wp_get_attachment_image_src($user_photo);
echo '<img class="author-picture" src="'. $image_src[0] .'" />';
Copy link

I wanted to display a user's profile photo (a custom field) on a team page. They are now able to enter their login name, and it will display their photo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment