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}