title: Get all users associated with a custom post type in WordPress
body: <p>I have a custom post type <code>institutions</code> that are associate users. </p>
  
  <p>Whenever I add a new user, I can select which institution he/she is associated with via <code>Advanced Custom Fields</code> plugin.</p>
  
  <p>Now that the set up is done, I am trying to display a list of all users associated with the institution I am currently viewing (<code>single-institutions.php</code>)</p>
  
  <p>I cannot use <code>WP_Query()</code> because it won't allow me to get the users and I can't use <code>wp_list_authors()</code> because it won't allow the <code>meta_query</code>.</p>
  
  <p>So I am left with using the old fashioned mysql query.</p>
  
  <p>But I'm not sure how to proceed because I need to query multiple tables in order to get the proper result.</p>
  
  <pre><code>wp_users: ID
  wp_usermeta
      user_id
      meta_key: institution
      meta_value: a:1:{i:0;s:4:"2875";} // "2875" is the ID of the institution the user is associated with
  </code></pre>
  
  <p>How can I achieve this with a direct mysql query?</p>
  
  <p>EDIT: I've switched to <code>WP_User_Query()</code> instead, I had no idea it existed. However, I am unsure what to put in <code>meta_value</code></p>
  
  <pre><code>$args = array(
    'role'           =&gt; 'Author',
    'order'          =&gt; 'ASC',
    'orderby'        =&gt; 'display_name',
    'who'            =&gt; 'authors',
    'exclude'        =&gt; [1, 7],
    'count_total'    =&gt; true,
    'meta_key'       =&gt; 'institution',
    'meta_value'     =&gt; $post-&gt;ID
  );
  
  // The User Query
  $user_query = new WP_User_Query( $args );
  
  // The User Loop
  if ( ! empty( $user_query-&gt;results ) ) {
    foreach ( $user_query-&gt;results as $user ) {
      echo $user-&gt;display_name . '&lt;br&gt;';
    }
  } else {
    // no users found
  }
  </code></pre>
  
  <p>Right now, nothing gets displayed. If I remove "meta_value" from the query, all users associated with any institution appear on all pages.</p>
  
  <p>How do I narrow it down to match the institution ID (<code>$post-&gt;ID</code>) I am currently viewing?</p>
  
  <p>This is the value of <code>meta_value</code> column in <code>wp_usermeta</code> table. It's serialized. Do I need to do anything special to retrieve the ID at the end?</p>
  
  <pre><code>a:1:{i:0;s:4:"2875";}
  </code></pre>