1

For the 'content' Views one can simply check tickbox 'Disable access checks' in UI under Advanced => Query, and the View returns all the records regardless of the node_access check.

However, in the 'content revisions' Views this tickbox is not available.

How can I make 'content revisions' Views to bypass the access_check?

1

In the hook_views_query_alter is possible to alter the query tags. Unfortunately, the method tag_remove is not present, but the $tags variable is public, which allows us to do:

function yourmodule_views_query_alter(&$view, &$query) {

    // Disable Node Access check for myview
    if ($view->name == 'myview') {
        $view->query->tags = [];
    }
}

I hope this will help somebody who needs unrestricted Views (e.g. for Services).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.