I'm using ACF to add custom fields to a User. I'm trying to output these fields to the front-end. I was able to pull all fields, but when I was trying to get the img it wouldn't pull.

Here's my code:

<?php $user_id = get_query_var( 'author' ) ?>
<?php $clan_member_info = get_userdata($user_id); ?>

<p><?php if(!empty($clan_member_info->psn_id)) echo '<li>' . $clan_member_info->psn_id . '</li>'; ?></p> //Example of me pulling a text field

<?php if(!empty($clan_member_info->cover_photo)) echo '<img src="'.$clan_member_info->cover_photo.'"/>'; ?>

The example of the psn_id pulls perfectly. The img returns this <img src="95">.

In the User section in WP, for my own User I uploaded a photo to the field. In the ACF field group I have the field to get "Image URL". I was hoping, if you look at the code, to spit the url into the src and output the img.

If I'm missing any data, I could provide a full pastebin url of the php file.

  • 1
    Have you read the documentation on the ACF website? There are plenty of examples there. advancedcustomfields.com/resources/…
    – ngearing
    Jun 9, 2016 at 1:14
  • @Nath Yes I've read this. I mentioned in my OP I can pull the data from a User. I've pulled text fields and url fields. The only field I cannot pull is image. I gave my example in the OP. Jun 9, 2016 at 2:28
  • 1
    Are you sure you read that? You are using object operators to grab values instead of the predefined functions in ACF.
    – jdm2112
    Jun 9, 2016 at 2:52
  • 1
    ACF stores the same value (ID) regardless of what you set the field to return. When you use the ACF API to fetch the value is when it is converted to URL instead of ID.
    – Milo
    Jun 9, 2016 at 2:52

1 Answer 1


When using ACF you should use the methods described in their website documentation because ACF does not store data in the normal Wordpress way.

You can use the get_field or the_field functions to retrieve data from your fields.

For example to get data for your field 'cover_photo' you could do:

$user_id = get_query_var( 'author' )
$cover_photo = get_field('cover_photo', 'user_'.$user_id);
// Assuming you have this field set to return a url
echo "<img src='$cover_photo'>";

For more information see: https://www.advancedcustomfields.com/resources/how-to-get-values-from-a-user/

  • I understand my error, I got it working. Thank you! Jun 9, 2016 at 5:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.