The code example given for hook_views_pre_view() claims that you can change the display by simply changing $display_id:
function hook_views_pre_view(&$view, &$display_id, &$args) {
// Change the display if the acting user has 'administer site configuration'
// permission, to display something radically different.
// (Note that this is not necessarily the best way to solve that task. Feel
// free to contribute another example!)
if (
$view->name == 'my_special_view' &&
user_access('administer site configuration') &&
$display_id == 'public_display'
) {
$display_id = 'private_display';
}
}
But this is not correct, you have to call $view->set_display() to do this.
This documentation issue only affects 7.x-3.x, in 8.x a different example is used.
Comments
Comment #1
pfrenssenComment #2
pfrenssenComment #3
moonray commentedRan into this issue. Patched example works.
Comment #4
dawehnerNext time just ping me and it won't be forgotten.
Comment #5
pfrenssenIt has not been committed yet to 7.x-3.x. Did you forget to push? :)
Comment #7
dawehnerPushed now