How to make exposed filters to hide filed with no value I am using exposed filters in Views to give user opportunity to select attribute.
I used field with taxonomy term as exposed filters.

As a result, exposed filter shows all possible variants for this field (all terms), instead which really were used in this material. I mean, that user can select any term from vocabulary even if I did not use this term in this content type material.
How to hide unused terms in exposed filters?
The below code comes from a current project of mine. I've made it more generic for your purposes, so it's untested. You'd need to modify the query depending on your usage - it's going to throw errors if you use as-is.

&lt;?php    
// Add this to a custom module, replace "mymodule" with your module name
function mymodule_form_views_exposed_form_alter(&amp;$form, &amp;$form_state) {
  //dsm($form); // Display available form vars
  $field_id = 'id_assigned_in_views'; // Change for the field ID in question.
  // Only alter forms with the necessary field.
  if (isset($form[$field_id])) {
    // Do your entity_field_query or db_query here
    $query = new EntityFieldQuery();
    $query-&gt;entityCondition('entity_type', 'taxonomy_term')
      -&gt;entityCondition('bundle', array('tags'))
      -&gt;propertyOrderBy('weight');
    $result = $query-&gt;execute();
    $terms = $result['taxonomy_term'];
    // Add a default so the filter is optional.
    $options = array('' =&gt; t('- All -'));
    foreach($terms as $tid=&gt;$term) {
      //dpm($term);
      $options[$tid] = $term-&gt;name;
    }
    // Alter the field.
    $form[$field_id]['#type'] = 'select';
    $form[$field_id]['#options'] = $options;
    $form[$field_id]['#size'] = 1;
  }
}
?&gt;