Render view for specific user, drupal_mail Is it possible to generate the content of the view as a specific user. So only the content the user has access to is rendered.

//Get view
$view = views_get_view("list_nodes");
//Pass arguments
$view-&gt;args = $locatie;
//Generate content
$content = $view-&gt;execute_display("block");


I got a custom module wich gets a list of users, to all those users the content of this view need to be send. But only the content the use has access to.
To render a view programmatically as a specific user, you need to adjust the global $user variable.

//Run script as a sepcific user
global $user;
$original_user = $user;
drupal_save_session(FALSE);
$user = user_load($uid);

//Your code goes here
....

//Return global variable to its orignal value
$user = $original_user;
drupal_save_session(TRUE);