Programmatically remove exposed filter in a view I would like to remove a certain exposed filter on the taxonomy term view when certain conditions in the URL are met.

For example, I want to remove the "Color" exposed filter when the user is seeing the /color/red taxonomy term page, leaving only the "Shape" filter available.

Or remove the "Shape" exposed filter on the /shape/square page, leaving only the "Color" one.

The only code I could come up with is this, which is ugly and doesn't even work. 

function hook_views_pre_render(&amp;$view){
      if( CONDITIONS_ARE_MET ) {
         unset($view-&gt;filter['field_color_tid']);
         unset($view-&gt;exposed_data['field_color_tid']);
         unset($view-&gt;exposed_raw_input['field_color_tid']);
      }
}


Any ideas?



UPDATE

This is the code in mmo_views_alters:

function mmo_views_alters_views_pre_build(&amp;$view){
    //dpm($view);
    unset($view-&gt;filter['field_tipologia_tid']);
}


This is the exported view: http://pastebin.com/JrYDmtZQ

It has 4 filters, and 3 of them are exposed. 
I'm using BEF for displaying them, which generated another warning (undefined index filter-field_tipologia_tid) that I solved by patching better_exposed_filters_exposed_form_plugin.inc, line 896:

if( isset($form['#info']["filter-$label"]['value']) )
        $field_id = $form['#info']["filter-$label"]['value'];
else continue;


The warnings that I'm not able to solve are:


  Notice: Undefined index: field_tipologia_tid in
  views_handler_filter_term_node_tid->exposed_validate() (linea 258 di
  /var/www/drupal/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc).
  
  Notice: Undefined index: field_tipologia_tid in
  views_handler_filter_term_node_tid->exposed_validate() (linea 259 di
  /var/www/drupal/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc).


They appear even with BEF disabled.
Implement hook_views_pre_build() and unset using unset($view-&gt;filter['field_color_tid']);

Else, you can also try altering the exposed form in hook_form_alter() using the code $form['field_tipologia_tid']['#access']=FALSE;