📅  最后修改于: 2022-03-11 14:54:07.640000             🧑  作者: Mango
function hook_views_pre_view(ViewExecutable $view, $display_id, array &$args) {
// Modify contextual filters for my_special_view if user has 'my special permission'.
$account = \Drupal::currentUser();
if ($view
->id() == 'my_special_view' && $account
->hasPermission('my special permission') && $display_id == 'public_display') {
$args[0] = 'custom value';
}
}