My task is to create a field that is visible to the author node.

Let's say the content type is "article" and the field is "textid" that contains the node ID number.

I've already created it with Display suite as a custom field with token [node:nid], so the result is some text with number of the node ID.

How can I make that field visible only by the node author?

What hook should I use?

  • Visible for edit or on the node view page?
    – Mołot
    Commented Oct 18, 2013 at 9:05
  • On the node view page.
    – user22957
    Commented Oct 18, 2013 at 9:07

1 Answer 1


You can simply use Field Permissions module:

Author-level permissions allow viewing and editing of fields based on who the entity owner is.

This seems to be exactly what you need.

To have real field (not display suite element), you can use Computed Field - more complicated than Display Suite, true, but at the same time more versatile and integrates well with everything field-related.

On the other hand, you can forget all these modules, and in your node.tpl.php simply compare current user id with node author's id, and if they are equal, print your data.

  • 1
    I had just copied the link to the module ready to paste into this exact same answer ;-). +1 for Field Permissions.
    – Chapabu
    Commented Oct 18, 2013 at 9:10
  • 1
    @Chapabu you beat me the same way couple of times, too :P OPs need was pretty popular and easy to answer, I guess.
    – Mołot
    Commented Oct 18, 2013 at 9:11
  • Hmm, I have problem here. The field is created with Display suite/custom field and Field Permission module cannot set permission to it.
    – user22957
    Commented Oct 18, 2013 at 9:17
  • @user22957 oh, so it is not really a field in Drupal 7 meaning? Need a bit more time to think about it, then
    – Mołot
    Commented Oct 18, 2013 at 9:19
  • 1
    I've ended up by creating a field with FAPI from the UI, and set a default text and I'll remove the access in the form by hook_form_alter. The field permission module is working perfectly when the field is created by the FAPI UI. In future I guess it will be better not to use often this custom fields with Display suite 'cos it's very limited.
    – user22957
    Commented Oct 18, 2013 at 15:08

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.