Home Forums Add-ons Flexible Content Field Infinite loop using user_id


Infinite loop using user_id

  • 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') {
            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)) {
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Infinite loop using user_id’ is closed to new replies.