Reputation: 11
I am really new at php , so sorry for this very basic question; i am using ACF to add a metabox to the user profile. So every user has a pic. The field is called 'badge', this is defined as an image object (but I don't know if that is correct, I just want the pic to appear on the page)
Then, I try to display the result on each profile page. On the documentation of acf: http://www.advancedcustomfields.com/resources/image/
so I tried this:
<img src="<?php echo $badge['url']; ?>" alt="<?php echo $badge['alt']; ?>" />
But I am getting lost here. I don't know how to retrieve the correct information and display it.
Could someone please help?
Many thanks, and sorry again for this very basic question i guess!
Sonia
Upvotes: 1
Views: 1101
Reputation: 648
It's been a while since the question has been asked, but here's a working code exemple of what you can do to retreive the Badge custom field on the current logged user:
<?php
$user = "user_".$user_ID;
$badge = get_field('avatar', $user);
?>
<img src="<?php echo $badge['url']; ?>" alt="<?php echo $badge['alt']; ?>" />
Hope it will help for the future!
Upvotes: 1