Add views exposed filter programmatically I used the below code in hook_views_pre_view to add two exposed filter to a view, the first filter which provides available brand works perfectly but the second filter is not added at all, no error is logged though, any help on that?

  $available_brands = dpspec_get_available_brand_name($mid);

  $filter_options = array(
    'value' =&gt; $available_brands,
    'exposed' =&gt; TRUE,
    'reduce_duplicates' =&gt; TRUE,
    'type' =&gt; 'select',
    'required' =&gt; FALSE,
    'expose' =&gt; array(
      'operator_id' =&gt; 'field_brand_op',
      'label' =&gt; t('Brand'),
      'operator' =&gt; 'field_brand_op',
      'identifier' =&gt; 'sp_brand',
      'reduce' =&gt; TRUE,
      'vocabulary' =&gt; 'tags',
      'multiple' =&gt; TRUE,
    ),
  );
  $view-&gt;add_item($view-&gt;current_display, 'filter', 'field_data_field_brand', 'field_brand_tid', $filter_options);

  $available_colors = dpspec_get_available_color_names($mid);
  $options = array(
    'value' =&gt; $available_colors,
    'exposed' =&gt; TRUE,
    'reduce_duplicates' =&gt; TRUE,
    'type' =&gt; 'select',
    'required' =&gt; FALSE,
    'expose' =&gt; array(
      'operator_id' =&gt; 'field_color_op',
      'label' =&gt; t('color'),
      'operator' =&gt; 'field_color_op',
      'identifier' =&gt; 'sp_color',
      'reduce' =&gt; TRUE,
      'vocabulary' =&gt; 'tags',
      'multiple' =&gt; TRUE,
    ),
  );

  $view-&gt;add_item($view-&gt;current_display, 'filter', 'field_data_field_color', 'field_color_tid', $options);
OK the code is working fine, the only problem was that the color field was added to product, while views was set based on node, so when I added a relation to product, it started working.