Hi there, I created a user field which generates a dropdown with all user. Great! Now, i need to print the choosen user name into my single.php template but I can’t do this. I found no documentation about it, only about getting values having selected ID (but I don’t have my choosen ID!). So, how to do that? 🙁
You can get the username by using something like:
$user_field = get_field('user_field_name');
if ( $user_field ) {
$user_info = get_userdata( $user_field['ID'] );
echo 'Username: ' . $user_info->user_login;
}
Great it works! Thank you Timothy!
I hope Elliot will put this into documentation 🙂