Support

Account

Home Forums General Issues Get label from User Custom Field Reply To: Get label from User Custom Field

  • @korndev

    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).