Created
August 12, 2014 23:28
-
-
Save mattradford/6941c242a4ff1aa4fd93 to your computer and use it in GitHub Desktop.
WordPress - custom user photo from user login name (via custom field)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$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] .'" />'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.