title: How can I filter records in custom post type list in admin based on user_id that passed as a query string parameter
body: <p>Is there any option that I can further filter post list for a custom post type in admin based on user_id if the same has been passed as a query string like <code>http://album.multibaselocal.com/wp-admin/edit.php?post_type=albums&amp;user_id=31</code> ?</p>
  
  <p>Here is what I want to accomplish:</p>
  
  <p>I have a custom post type called <code>album</code> which is used by site users to upload Albums to the system. By default when I go to the list page all albums come up fine. In user list page, I have added a custom column which shows a count of Published albums by each user which links back to album list page with a query string <code>user_id</code> like above.</p>
  
  <p>I want to filter the albums by the <code>user_id</code> I have passed. Is this possible?</p>
  
  <p>I am trying this:</p>
  
  <pre><code>add_filter( 'parse_query', 'filter_albums_further_if_user_id_found');
  
  function filter_albums_further_if_user_id_found($query) {
      if( isset($_GET['user_id']) &amp;&amp; !empty($_GET['user_id'])) {
          $user_id = $_GET['user_id'];
  
          $requery = array(
              'post_type' =&gt; 'albums',
              'post_author' =&gt; $user_id,
              'status' =&gt; 'publish',
              'posts_per_page' =&gt; -1,
          );
  
          // What to do here?
      }
  }
  </code></pre>
  
  <p>I have lost here completely. Not an experienced WP developer!</p>
  
  <p>If I have not understood it all wrong, because the hook I am using is called <code>parse_query</code>, I have to somehow parse the query again and filter the existing result using <code>user_id</code>. But don't know where and how.</p>
  
  <p><strong>EDIT (Query output):</strong></p>
  
  <pre><code>WP_Query Object
  (
      [query] =&gt; Array
          (
              [post_type] =&gt; albums
              [posts_per_page] =&gt; 20
          )
  
      [query_vars] =&gt; Array
          (
              [post_type] =&gt; albums
              [posts_per_page] =&gt; 20
              [error] =&gt; 
              [m] =&gt; 
              [p] =&gt; 0
              [post_parent] =&gt; 
              [subpost] =&gt; 
              [subpost_id] =&gt; 
              [attachment] =&gt; 
              [attachment_id] =&gt; 0
              [name] =&gt; 
              [static] =&gt; 
              [pagename] =&gt; 
              [page_id] =&gt; 0
              [second] =&gt; 
              [minute] =&gt; 
              [hour] =&gt; 
              [day] =&gt; 0
              [monthnum] =&gt; 0
              [year] =&gt; 0
              [w] =&gt; 0
              [category_name] =&gt; 
              [tag] =&gt; 
              [cat] =&gt; 
              [tag_id] =&gt; 
              [author] =&gt; 
              [author_name] =&gt; 
              [feed] =&gt; 
              [tb] =&gt; 
              [paged] =&gt; 0
              [meta_key] =&gt; user_id
              [meta_value] =&gt; 31
              [preview] =&gt; 
              [s] =&gt; 
              [sentence] =&gt; 
              [title] =&gt; 
              [fields] =&gt; 
              [menu_order] =&gt; 
              [embed] =&gt; 
              [category__in] =&gt; Array
                  (
                  )
  
              [category__not_in] =&gt; Array
                  (
                  )
  
              [category__and] =&gt; Array
                  (
                  )
  
              [post__in] =&gt; Array
                  (
                  )
  
              [post__not_in] =&gt; Array
                  (
                  )
  
              [post_name__in] =&gt; Array
                  (
                  )
  
              [tag__in] =&gt; Array
                  (
                  )
  
              [tag__not_in] =&gt; Array
                  (
                  )
  
              [tag__and] =&gt; Array
                  (
                  )
  
              [tag_slug__in] =&gt; Array
                  (
                  )
  
              [tag_slug__and] =&gt; Array
                  (
                  )
  
              [post_parent__in] =&gt; Array
                  (
                  )
  
              [post_parent__not_in] =&gt; Array
                  (
                  )
  
              [author__in] =&gt; Array
                  (
                  )
  
              [author__not_in] =&gt; Array
                  (
                  )
  
          )
  
      [tax_query] =&gt; WP_Tax_Query Object
          (
              [queries] =&gt; Array
                  (
                  )
  
              [relation] =&gt; AND
              [table_aliases:protected] =&gt; Array
                  (
                  )
  
              [queried_terms] =&gt; Array
                  (
                  )
  
              [primary_table] =&gt; 
              [primary_id_column] =&gt; 
          )
  
      [meta_query] =&gt; 
      [date_query] =&gt; 
      [post_count] =&gt; 0
      [current_post] =&gt; -1
      [in_the_loop] =&gt; 
      [comment_count] =&gt; 0
      [current_comment] =&gt; -1
      [found_posts] =&gt; 0
      [max_num_pages] =&gt; 0
      [max_num_comment_pages] =&gt; 0
      [is_single] =&gt; 
      [is_preview] =&gt; 
      [is_page] =&gt; 
      [is_archive] =&gt; 1
      [is_date] =&gt; 
      [is_year] =&gt; 
      [is_month] =&gt; 
      [is_day] =&gt; 
      [is_time] =&gt; 
      [is_author] =&gt; 
      [is_category] =&gt; 
      [is_tag] =&gt; 
      [is_tax] =&gt; 
      [is_search] =&gt; 
      [is_feed] =&gt; 
      [is_comment_feed] =&gt; 
      [is_trackback] =&gt; 
      [is_home] =&gt; 
      [is_404] =&gt; 
      [is_embed] =&gt; 
      [is_paged] =&gt; 
      [is_admin] =&gt; 1
      [is_attachment] =&gt; 
      [is_singular] =&gt; 
      [is_robots] =&gt; 
      [is_posts_page] =&gt; 
      [is_post_type_archive] =&gt; 1
      [query_vars_hash:WP_Query:private] =&gt; 1c0b485390fc9607d8008a14177bd63d
      [query_vars_changed:WP_Query:private] =&gt; 
      [thumbnails_cached] =&gt; 
      [stopwords:WP_Query:private] =&gt; 
      [compat_fields:WP_Query:private] =&gt; Array
          (
              [0] =&gt; query_vars_hash
              [1] =&gt; query_vars_changed
          )
  
      [compat_methods:WP_Query:private] =&gt; Array
          (
              [0] =&gt; init_query_flags
              [1] =&gt; parse_tax_query
          )
  
  )
  </code></pre>
  
  <p><strong>EDIT (Function body presently using):</strong></p>
  
  <pre><code>add_action( 'pre_get_posts', 'filter_albums_further_if_user_id_found');
  
  function filter_albums_further_if_user_id_found($query) {
      if(!is_admin())
          return;
  
      if( isset($_GET['user_id']) &amp;&amp; !empty($_GET['user_id']) ) {
          $user_id = $_GET['user_id'];
  
          $query-&gt;set('meta_key', 'user_id');
          $query-&gt;set('meta_value', $user_id);
  
      }
  
      echo '&lt;pre&gt;'; print_r($query); echo '&lt;/pre&gt;'; die();
  }
  </code></pre>