Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

views_pre_view

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';
  }
}
Source by api.drupal.org #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
8+8 =