ok thank you !
I may be a little abuse, but do you know exactly how to get this value “custom field”?
As the “custom field” displays the ID user2, perhaps it is enough to retrieve the value without using get_field but get_post_custom_value?
Below the screenshot.
The field is located in a “post custom” type I created called Author. In the edit page, there are many in the “custom field” user2 = a number.
This shows my username and not the user selected in the ACF User Field.
Yes it works, but I want to get the id of get_field(‘ACF’); (from ACF User field) exactly like:
$userID = get_field('user2');
$theuser = get_userdata($userID);
echo 'Username: ' . $theuser->user_login;
Thank you, but…
I tried to recover the username but nothing is displayed.
$userID = get_field('user2');
$theuser = get_userdata($userID);
echo 'Username: ' . $theuser->user_login;
I noticed with the code the_field(‘USER2’) showed that all of the information user.
But with $user2 = get_field(‘USER2′) and echo $user2; nothing is displayed. Even with this code where it does not work:
$user2 = ’20’; (id of a user) $theuser = get_userdata($user2) does not retrieve the value.
So if I try $theuser = get_userdata(20); echo $theuser->user_login; it’s ok…
Thank you elliot for your reply.
1. How to get the data?
2. oups, my english is bad, so google translate from french to english 🙂
If you explain me how to get the data (from the array) of the User Field, I think I can handle it.
😉 Surely!
Maybe I misspoke. These two different questions on the same topic:
1) what is the “User Field” which allows a user to choose? How to retrieve the selection and as if she appears?
2) In fact, for various reasons, I create a Custom Post Type “Author”. The template “Author” display the Related Posts. My skills are limited so that’s what I wanted to do because they are not Users who created the items, but the Admin:
– Creation of the User;
– Creation of the page for that User (-> Author)
– In the Author, page selection in the fields User affiliate.
– In the code view the posts created by this User / Author
I hope you can help me, I tear a little hair there.
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.