Home › Forums › Add-ons › Repeater Field › Acf while loop if any rows return this value once? › Reply To: Acf while loop if any rows return this value once?
I think I understand the question.
You want to show the entire thing, including the header, if any of the lines in the repeater are for the user.
I would use a PHP output buffer like this
ob_start();
$has_output = false;
echo '<h3>' . $download_headline . '</h3>';
while ( have_rows('section_download', 'options_customer') ) : the_row();
//File restricted to
$file_restriction = get_sub_field('role_restriction');
//Current user group
$wcb2b_current_user_group = get_the_author_meta( 'wcb2b_group', $current_user->ID );
if( in_array($wcb2b_current_user_group, $file_restriction ) ) {
$has_output = true;
// generate content
}
endwhile;
$output = ob_get_clean();
if ($has_output) {
echo $output;
}
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.