Support

Account

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…