How do I print a link only if it doesn't lead to access denied
Now I feel silly, found an answer myself straight away, although it does only work for this specific example, I'd still be interested to see something more general.

&lt;?php if (node_access('update', $node)):
    print l('edit', 'node/' . $nid . '/edit');
endif; ?&gt;