How to add an argument to a view programmatically? I want to add an argument to a view. I want to set this argument programmatically (not by url).

The field i want to filter is not directly in the view query, because this is a field on a node reference, so I cannot use hook_views_query_alter.

How can i can add programmatically an argument to a view?
I mean, which hook is better to do it?
You can use hook_views_pre_view and set arguments you want. For example

function hook_views_pre_view(&amp;$view, &amp;$display_id, &amp;$args) {
  if ($view-&gt;name == 'your_view_name') {
     $view-&gt;set_arguments(array('arg1', 'arg2'));
  }
}