views pre view

Solutions on MaxInterview for views pre view by the best coders in the world

showing results for - "views pre view"
Michelle
12 Jan 2020
1function hook_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
2
3  // Modify contextual filters for my_special_view if user has 'my special permission'.
4  $account = \Drupal::currentUser();
5  if ($view
6    ->id() == 'my_special_view' && $account
7    ->hasPermission('my special permission') && $display_id == 'public_display') {
8    $args[0] = 'custom value';
9  }
10}