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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.