View with paged output - how to alter number of pages? I use Views 7.x-3.8.
I have view "taxonomy_term". It has Paged output, full pager. Number of pages (the total number of pages) is set to 100, Items per page = 10.
Now I want to show all pages for users with proper permission.

I tried to set pager option 'total_pages' to empty string in hook_views_pre_execute():

function MYMODULE_views_pre_execute(&amp;$view) {
  if ($view-&gt;name == 'taxonomy_term') {
    if (user_access('view all pages')) {
      $view-&gt;query-&gt;pager-&gt;options['total_pages'] = '';
    }
  }
}


It actually works with pager: users with permission 'view all pages' can view page #101, #102 and so on, but nodes on these pages (more than #100) are the same as on page #100. It means that query has not changed, and query limit is still 1000 (10 items x 100 pages).
I tried

$view-&gt;query-&gt;set_limit(0);


in hook_views_pre_execute() and

$view-&gt;query-&gt;set_limit(0);
$query-&gt;set_limit(0);


in hook_views_query_alter(), but it's not working.

I also tried to set $view->query->offset and $view->offset manually:

$view-&gt;query-&gt;offset = $view-&gt;offset = $view-&gt;query-&gt;pager-&gt;current_page * $view-&gt;query-&gt;limit;


with no effect.

What am I missing? How to change number of view' total pages AND query results programmatically?
I did it:

function MYMODULE_views_pre_execute(&amp;$view) {
  if ($view-&gt;name == 'taxonomy_term') {
    if (user_access('view all pages')) {
      $view-&gt;query-&gt;pager-&gt;options['total_pages'] = NULL;
      $query = $view-&gt;build_info['query'];
      $offset = $view-&gt;query-&gt;pager-&gt;current_page * $view-&gt;query-&gt;limit;
      $query-&gt;range($offset, $view-&gt;query-&gt;limit);
    }
  }
}