Display text according to the access to a field With field permissions, I restrict the access of a field to certain users. 

I would like to display some text to inform the user that he has no access to the field. 

I tried it in node.tpl.php :

&lt;?php if (!field_access('view', field_info_field('field_name'),'node', $node)): ?&gt;
    &lt;p&gt;&lt;?php print t('my text.'); ?&gt;&lt;/p&gt;
&lt;?php endif; ?&gt;


It works, but I do not know how to restrict according to the type of content.

How can it be done? 
Also, is it the good method?
You can use drupal_set_message in hook_node_view to display the text as a message to the users.

function MODULE_NAME_node_view($node, $view_mode, $langcode) {
  if ($node-&gt;type == 'your_node_type') {
    if (!field_access('view', field_info_field('field_name'),'node', $node)) {
      drupal_set_message(t('Your text.'), 'warning');
    }
  }
}