How to change programmatically exposed filters in views I have a page view with exposed filters. One of the filters is term vocabulary, and that's dropdown list, user can select only one category (term). 

I want to set programmatically one term from dropdown list when I came from specific URL. I tried with views_query_alter where $category is tid. 

 $set_exposed_input  = array();
 $set_exposed_input['field_category_tid'] = $category;

 if ($set_exposed_input) {
    $view-&gt;set_exposed_input($set_exposed_input);
 }
For drupal 7 you can use

$view-&gt;exposed_input[$key] = $value;


This is

$view-&gt;exposed_input['title'] = 'My title is a cat';


For a full example you can try this:

$name = 'name_of_view';
$display = 'page_1';
$alter = array('exposed' =&gt;array('title' =&gt; 'title_value'));

$view = views_get_view($name);
$view-&gt;init_display($display);
$view-&gt;preview=TRUE;
$view-&gt;is_cacheable = FALSE;


if(isset($alter['exposed'])){
  foreach($alter['exposed'] as $key =&gt; $valor){

     $view-&gt;exposed_input[$key] = $valor;

  }
}

$view-&gt;pre_execute();
$output = $view-&gt;display_handler-&gt;preview();
$view-&gt;post_execute();

print_r($view-&gt;result);


Other way is using the views set_option function

$filters = $view-&gt;display_handler-&gt;get_option('filters');

foreach($alter['exposed'] as $key =&gt; $valor){
   $filters[$key]['value'] = $valor;
   $view-&gt;display_handler-&gt;set_option('filters', $filters);
}