3

I'm using Nodeaccess module to add permissions on specific nodes. in my .theme file I want to Check if the current user has permission to edit the current node.

  • Shouldn’t this be handled by the route callback / link function? – Kevin May 18 '18 at 0:43
  • @Kevin, Thanks for your help. Can you provide me with some details or link help me using callback / link function. – Mohamed Osama Gbril May 18 '18 at 1:00
5

I've found it and working great.

  $node = \Drupal\node\Entity\Node::load(NID);
  $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
  $check = $node->access('update', $user);

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.