Alter views with hook_views_query_alter()
I found a slightly different solution that works.

Instead of adding programatically the relation, I instead added a clause in $query-&gt;where

function taxonomy_location_views_query_alter(&amp;$view, &amp;$query) {
  $tid = subdomain_get_sid(subdomain_get_current_subdomain());
  if($tid) {
    $query-&gt;where[0]['clauses'][] = "(node.vid IN (SELECT tn.vid FROM term_node tn WHERE tn.tid = %d))";
    $query-&gt;where[0]['args'][] = $tid;
  }
}