I have created a field in the backend that applies to each user. When I add values to a user and log in as that user it displays the value set in the back end but then infinitely loops the while loop. The result is a infinite string of End of if after the values set in the user account.
$user_id = get_current_user_id();
$values = have_rows('user_notification', 'user_'.$user_id);
if ($values){
echo 'Is set <br><br>';
while ($values) { the_row();
if (get_row_layout() == 'notification') {
the_sub_field('notification_title');
}
echo 'End of if <br>';
}
}
This returns true or false
$values = have_rows('user_notification', 'user_'.$user_id);
Which means that
while ($values)
is always true
The correct way to do this loop is
if (have_rows('user_notification', 'user_'.$user_id)) {
while (have_rows('user_notification', 'user_'.$user_id)) {
the_row();
}
}