It looks like we don’t explicitly support the ACF user field yet, but if Emmanuel is correct that <Field user_customfield /> outputs the user ID (you might need to set the field return output to User Object in your ACF field group setup), it can then be passed to a user loop to get a user’s data:
@eliot I am using a user loop and I have ACF fields on the users. Text fields are working, but as you can see below, I have a custom field for headshot, and even though the ACF field is set to return image url, it will only return the image ID. So I’m getting this on the frontend:
Hey @zack, that’s a great question and it’s one that I had to ask the team myself a few weeks back so I figured I’d chime in to share what I learned.
The way WordPress works is that when you upload an image to a custom field you’ve created, you’re not actually adding an image directly to that field. Instead, you’re creating a new “attachment” post (attachments are a unique default WordPress post type just like pages and posts) and you’re then telling WordPress “hey, this user as an attachment post associated with it and you can find that attachment using this post ID.” That’s why when you use the Field author_headshot tag to try to grab the image, all you’re getting is the ID of that attachment.
The way to get your image is pretty simple, it just requires creating another loop to tell WordPress to go grab the actual image URL that’s associated with a given attachment post ID. In practice, that would just look like this where you’re creating an attachment based on the post ID and then getting any of the fields available in an attachment loop, in your case probably url:
Now you may be asking yourself (as I did): “why do I need a nested attachment loop to do this when normally I can just use tags like <Field image> to grab a post’s featured image directly without an attachment loop?” Well, it turns out that featured images are image arrays, which are saved differently than image attachments and therefore don’t require a separate search through the database to get the image.
I hope that’s helpful!
Oh and one last tiny tip: no need to add the closing / to your tags when they’re inside curly braces
Thank you @benjamin for explaining about the image field, and how the attachment loop is used to get fields from the image itself. Good info about the difference between featured image, which WordPress handles specially, and ACF image fields, which WordPress doesn’t know anything about and simply treats it as a number (the attachment ID).
The alt text may be used by screen readers and other assistive technologies to help differently-abled users make full use of your content. It will be read aloud or sent to the touch device, for example, to support visually impaired users.