Support

Account

Home Forums Backend Issues (wp-admin) How do you access a User ACF field from a Post Query? Reply To: How do you access a User ACF field from a Post Query?

  • 
    // get the current user id and then get the company name associated with user
    $user_id = get_current_user();
    $company = get_field('company_name', 'user_'.$user_id);
    
    // get a list of user IDs associated with the above company name
    $args = array(
      'meta_key' => 'company_name,
      'meta_value ' => $company,
      'fields' => 'ID'
    )
    $users = new WP_User_query($args);
    

    I’m not sure how the posts you want to get relate to the list of user IDs