1

I'm using Display Suite custom fields to have the edit link rendered somewhere else on the node page. Is there an easy way to verify the currently logged-in user has the permission to edit the node?.

So far I tried this code.

global $user;

if (node_access('update', $nid, $user)) {
  echo l(t('Edit this node'), 'node/' . $node->nid . '/edit');
}

What code should I instead use?

0

1 Answer 1

1

It might be that you don't have access to the node object, in which case changing to the following should work...

<?php 
  global $user;
  if ($node = node_load(arg(1))) {
    if (node_access('update', $node, $user) == true) {
      echo l(t('Edit this node'), 'node/' . $node->nid . '/edit');
    }
  }
?>

Your Answer

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