Support

Account

Home Forums ACF PRO How to retrieve Name from ACF User field type?

Solved

How to retrieve Name from ACF User field type?

  • 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 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘How to retrieve Name from ACF User field type?’ is closed to new replies.