1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
add_filter('pre_get_posts', 'oqp_guest_pre_get_posts');

function oqp_guest_pre_get_posts($query) {
  global $post;

  $dummy_ID = 3; //ID of the "guest" account

  $query_author_ID = $query->query_vars['author'];

  if ($query_author_ID!=$dummy_ID)return $query; //author is not the dummy user

  $query->set('author_name', false);
  $query->set('author', false);

  $dummy_email = get_post_meta($post->ID,'oqp_guest_email', true); //gives me test@test.com

  if (!$dummy_email) return $query; //no key to analyze

  $query->set('meta_key', 'oqp_guest_email');
  $query->set('meta_value', $dummy_email);

  print_r($query); //see the output below

  return $query;

}

query "printed" before the loop :

1
2
WP_Query Object ( [query_vars] => Array ( [post_type] => yclad [orderby] => date [posts_per_page] => 5 [post__not_in] => Array ( [0] => 2331 ) [author] => [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [category_name] => [tag] => [cat] => [tag_id] => [author_name] => [feed] => [tb] => [paged] => 0 [comments_popup] => [meta_key] => oqp_guest_email [meta_value] => pipi@caca.com [preview] => [s] => [sentence] => [fields] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [meta_query] => Array ( ) ) [tax_query] => WP_Tax_Query Object ( [queries] => Array ( ) [relation] => AND ) [post_count] => 0 [current_post] => -1 [in_the_loop] => [comment_count] => 0 [current_comment] => -1 [found_posts] => 0 [max_num_pages] => 0 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => 1 [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => 1 [is_category] => [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_404] => [is_comments_popup] => [is_paged] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => [parsed_tax_query] => 1 [query] => Array ( [post_type] => yclad [orderby] => date [posts_per_page] => 5 [post__not_in] => Array ( [0] => 2331 ) [author] => 3 ) )