hook_views_pre_view(ViewExecutable $view, $display_id, array &$args)
Alter a view at the very beginning of Views processing.
Output can be added to the view by setting $view->attachment_before and $view->attachment_after.
\Drupal\views\ViewExecutable $view: The view object about to be processed.
string $display_id: The machine name of the active display.
array $args: An array of arguments passed into the 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->name == 'my_special_view' && $account->hasPermission('my special permission') && $display_id == 'public_display') { $args[0] = 'custom value'; } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!views!views.api.php/function/hook_views_pre_view/8.1.x