Home › Forums › General Issues › Get label from User Custom Field › Reply To: Get label from User Custom Field
Try using get_field_objects() including the (user) ID, as in:
$user_meta = get_field_objects('user_' . $userID);
foreach($user_meta as $meta) :
if (strpos($meta['name'], 'user_q_') !== FALSE) { ?>
<h3><?php echo $meta['label']; ?></h3>
<div><?php echo $meta['value']; ?></div>
<?php }
endforeach;
Notice the field key is returning the field’s name prefixed with “field_” – this means ACF can’t find the actual field object for the post (but it can find the meta_value).
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.