Home › Forums › Add-ons › Repeater Field › Return repeater values by User value › Reply To: Return repeater values by User value
Hi @fontsnob,
You can check if the current user is the selected user like this:
// check if the repeater field has rows of data
if( have_rows('repeater_field_name') ):
// loop through the rows of data
while ( have_rows('repeater_field_name') ) : the_row();
$currentUserID = get_current_user_id();
$allowedUser = get_sub_field('user_sub_field_name');
if($currentUserID == $allowedUser['ID']){
the_sub_field('other_sub_field_name');
}
endwhile;
else :
// no rows found
endif;
Please change the field name according to your field name. You can also debug the user field value by using var_dump(). This page should give you more idea about it: http://www.advancedcustomfields.com/resources/debug/.
I hope this helps.
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.