How can I programatically determine whether a certain user has "view" (or any other operation) permission for a given node?

I'm trying this, but it doesn't seem to be calling the node access hooks, and it's overall pretty ugly:

$node_grant_storage = \Drupal::service('node.grant_storage');

$current_user_has_access = is_a(

Ideally I'd like something to return a boolean and not a class (I have no use for the "neutral" option here, I just want to know if a user went into the node/X page, would they get a 403 or not).

1 Answer 1


This was easier than it seemed:

$current_user_has_access = $node->access();

This function has an optional parameter where you can pass an arbitrary user account, which defaults to the logged in user (suits my purpose).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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