Home › Forums › Front-end Issues › Custom fields in repeater users › Reply To: Custom fields in repeater users
Hi Elliot,
The extra fields are to extend the WP standard user. After doing a remake of a large local government site a few years ago I like to try and keep all ‘people’ in one place.
After a bit of mucking around I got that to work. For the benefit of anyone else doing this here’s the code.
<?php if(get_field('people')): ?>
<?php while(has_sub_field('people')): ?>
<ul class="person">
<?php $person=get_sub_field('person'); ?>
<?php $person_id=$person['ID'];
$cell = get_field('cell', "user_{$person_id}");
$phone = get_field('phone', "user_{$person_id}");
$firstname=$person['user_firstname'];
$lastname=$person['user_lastname'];
$email=$person['user_email'];
$userid=get_field('user_{$person_id');
echo $personid;
?>
<li> <?php echo get_avatar( $email, $size, $default, $alt ); ?> </li>
<li class="persondetails">
<?php echo $firstname; ?>
<?php echo $lastname; ?>
<?php echo $email; ?>
<?php if ($cell != '0'){ ?>Cell: 0<?php echo $cell; ?><?php } else {} ?>
<?php if ($phone != '0'){ ?>Phone: <?php echo $phone; ?><?php } else {} ?>
<?php the_sub_field('person=>user_lastname'); ?>
<a href="<?php echo get_edit_user_link($person_id); ?>">edit person</a>
</li>
</ul>
<?php endwhile; ?>
<?php endif; ?>
The number fields seem to strip leading zeros and default to zero. Not sure if there’s a more sensible way of dealing with phone numbers, but this seems to work ok for me.
I wasn’t sure about using ‘user’ as a field name. It’s not a reserved word, but having multiple ‘user’ labels can make things pretty confusing.
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.