How can I run a query in the views in the context of the user?
E.g. using EntityFieldQuery
I can run
$query->addMetaData('account', user_load(1));
is there any equivalent for $view->query
?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityI've found possibility to do it in hook_views_post_build
:
function MY_MODYLE_views_post_build($view) {
if($view->name == 'MY_VIEW_NAME') {
$query = $view->build_info['query'];
$query->addMetaData('account', user_load(47));
}
}
I've noticed that we have SelectQuery
object only after query build (in views.inc $this->query->build($this);
).
After it only one hook is executed views_post_build
.