theme preprocess view I have a content type "Slide" that I use for a carousel in a view as a block. One of the field of the slide I have added is "country filter" that I intent to use as a filter for geo localisation. I use GeoIP2 for this.

My intent was to use a THEME_preprocess_SOMETHING() to alter the view and remove some of the slides that are not on the right country filter. For example some slides could be allowed to be shown only to user located in France. If the user is not located in France, I would remove those slides.

I tried to do this in a THEME_preprocess_view_view_fields() but I can seem to find a way to remove completely the slide. So I guessed I was not on the right hook.

Does anyone knows which hook I should use to do that?
I haven't found a way to do it in a THEME.theme file but I found a way to do it in a MODULE.MODULE file. The magic hook is MODULE_views_post_execute:

function feature_carrousel_views_post_execute(\Drupal\views\ViewExecutable $viewExecutable){
  /** @var \Drupal\views\Entity\View $view */
  $view = $viewExecutable-&gt;storage;
  if($view-&gt;id() == 'carrousel'){
    /** @var \Drupal\views\ResultRow $row */
    foreach($viewExecutable-&gt;result as $key =&gt; $row){
      $nid = $row-&gt;nid;
      /** @var \Drupal\node\NodeInterface $node */
      $node = \Drupal\node\Entity\Node::load($nid);
      if($node) {
        $country_filter = $node-&gt;get("field_country_filter")-&gt;getValue();
        $country_filter_tid = (reset($country_filter))['target_id'];
        /** @var \Drupal\taxonomy\Entity\Term $term */
        $term = \Drupal\taxonomy\Entity\Term::load($country_filter_tid);
        $name = $term-&gt;getName();
        $countryCode = getUserCountry();

        if(strtolower($name) != 'all' &amp;&amp; strtolower($name) != strtolower($countryCode)) {
          unset($viewExecutable-&gt;result[$key]);
          $viewExecutable-&gt;result = array_values($viewExecutable-&gt;result);
        }

      }
    }
  }
}


Cheers