Home › Forums › ACF PRO › User Relationship Field – Get User ID › Reply To: User Relationship Field – Get User ID
Pretty straight forward, heres how I usually do it.
$username = get_field('your_user_field_name'); // this gives us an array of all user data.. $userID = $username['ID']; // grabs the user ID // this could be a custom ACF field you added to the user screen $jobtitle = get_field('custom_user_field', 'user_'. $userID ); // grabs corresponding social info from user account $theemail = get_the_author_meta('user_email', $userID); $linkedin = get_the_author_meta('linkedin', $userID); $twitter = get_the_author_meta('twitter', $userID); $gplus = get_the_author_meta('googleplus', $userID);
You can look up get_the_author_meta for all of the other options available as well.
Edit: some screenshots.. This assumes you are using the actual “User” field type from ACF.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
CPT registration is coming to ACF! We demoed the new feature during the most recent session of ACF Chat Fridays. Check out the summary for the details. https://t.co/k2KQ3WWBAz— Advanced Custom Fields (@wp_acf) March 7, 2023
© 2023 Advanced Custom Fields.