Is it possible to run a View from code in a cron hook? I'm writing a queued cron process, and need to retrieve some information while doing this. Rather than fiddling around with DB queries, it seemed to me much easier to create a View and then execute it in the code. Which I did (and by the way, the View itself works fine and returns the expected result). Trouble is, although it seems to run fine, it returns no result.

I've tried two different ways of doing this, but both are the same: the result is empty.

First was very simple:

if (!isset($node-&gt;og_group_ref)) {
  $regions = views_get_view_result('og_regions');
  }


That left $regions empty, so I tried this, with no better result:

if (!isset($node-&gt;og_group_ref)) {
  $view = views_get_view('og_regions');
  $view-&gt;execute();
  $regions = $view-&gt;result;
  }
Problem sorted. It was all down to permissions, and loading user 1 as described in the blog linked to by my previous comment allowed the View to work as expected.