Support

Account

Home Forums Front-end Issues Values from user field

Solved

Values from user field

  • Hi, I’m struggling to find documentation on the User field, I’m assuming it works in a similar way to the Relationship field. I’ve managed to get the correct count, so if two users are selected the correct count appear but I’m struggling to get the actual meta values and custom fields. Just wondering if anyone has any pointers for what I’m overlooking, for reference I’ll add what I was working with. cheers.

    <?php $posts = get_field('teacher'); if( $posts ): ?>
    
    <?php foreach( $posts as $p): ?>
    <?php setup_postdata($p); ?>
    
    	<?php echo $p->user_login; ?>
    	<?php the_field('phone_number','user_'.$p->ID); ?>
    
    <?php endforeach; ?>
    <?php wp_reset_postdata(); ?>
    <?php endif; ?>
  • I’ve found I could use the following to store the User ID in a variable, after that, the world was my oyster.

    <?php $assigned_user = reset($post); ?>

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Values from user field’ is closed to new replies.