Output ACF repeater on frontend user’s profile page (created with Ultimate Member) [closed]

I managed to find a solution – perhaps it will be helpful for someone in the future… 🙂

This is function that will create a table similar to the repeater on the backend. In this case 4 columns – can be adjusted and styled as necessary.

function acf_repeater() {

$user_id = get_current_user_id();
ob_start(); ?>
<?php if( have_rows('repeater_name',"user_{$user_id}" ) ): ?>

<table>
   <tr>
    <td>Column 1 header</td><td>Column 2 header</td><td>Column 3 header</td><td>Column 4 header</td>
   </tr>

<?php while ( have_rows('repeater_name', "user_{$user_id}" ) ) : the_row(); 

    // vars
    $var1 = get_sub_field('subfield_1_name');
    $var2 = get_sub_field('subfield_2_name');
    $var3 = get_sub_field('subfield_3_name');
    $var4 = get_sub_field('subfield_4_name');

?>
    <tr>
        <td><?php echo $var1; ?></td><td><?php echo $var2; ?></td><td><?php echo $var3; ?></td><td><?php echo $var4; ?></td>
    </tr>


<?php endwhile; ?>

</table>
<?php else: echo '<span>No data</span>'; ?>
<?php endif; ?>
<?php $output = ob_get_clean();
return $output;
}

add_shortcode('acf_repeater_shortcode', 'acf_repeater');`