I have a link which goes to a page created by a custom module. The module implements hook_permission and hook_menu so that when a user without permission clicks the link they get sent to the page and are shown the 'You are not authorized to access this page' message.

Is there way I can 'unlink'/'de-anchor' the link, so that the link displays as just unclickable black text to those without permission?


1 Answer 1


Here's what I've come up with myself. It works fine:

if(user_access('edit record')) {
    $link = l(t('Edit this record'), 'edit-record/' . $nid);
} else {
    $link = t('Edit this record');

If you know of a 'cleaner' more 'correct' way. Please let me know. Thanks

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.