Home › Forums › Add-ons › Repeater Field › How to access user data inside a repeater loop › Reply To: How to access user data inside a repeater loop
Hi @acf_support — thanks for the reply.
I changed my code to this, but still no luck:
<?php
if( have_rows('episode_staff') ):
while ( have_rows('episode_staff') ) : the_row();
$user = get_sub_field('episode_staff_member');
?>
<div class="masthead-single">
<?php foreach ($user as $user):
$user_id = $user->ID ?>
<h4 class="masthead-name"><?php echo get_user_meta($user, 'first_name', true) ?> <?php echo get_user_meta($user, 'last_name', true) ?></h4>
<div class="masthead-title"><?php echo get_sub_field('twitter_username', 'user' . $user_id) ?>
</div>
<?php endforeach; ?>
</div>
<?php endwhile;
endif; ?>
I believe it is a problem with the loop, as the foreach loop is cycling through 10 times and there are only 2 episode_staff rows…
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.