Support

Account

Home Forums General Issues Using get_field to set a variable with values from a user Reply To: Using get_field to set a variable with values from a user

  • So then you’ll need to query the ‘wglocations’ to get all the posts for the user and then loop through those to build a list of all the numbers to look for

    
    $args = array(
      'post_type' => 'wglocations',
      'post_per_page' => -1,
      'author' => $user_id
    );
    $query = new WP_Query($args);
    $ring_numbers = array();
    foreach ($query->posts as $post) {
      $value = get_field('leg_ring_number', $post_id);
      $values = str_replace(' ', '', $ring_numbers);
      $ring_numbers = array_merge($ring_numbers, explode(',', $value));
    }
    

    Then you do the second query from the previous code