0

I'm trying to check user access to node via this code:

 $node = Node::load($node_id);   
 User::load(\Drupal::currentUser()->id());
 $node->access('view', $account)

It seems it doesn't check if user has access to node translation or not and it check only for first language of node -when we create node for first time.

For example if node is created in English as published and later in french as unpublished node access returns which user has access. If I update English language to unpublished and french to published, node->access returns false;

So node_access doesn't consider translation? How we can check for translations too?

1 Answer 1

1

You can just call getTranslation like this:

$node_translation = $node->getTranslation('LANGCODE');
0

Your Answer

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

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