Problem with specific permissions I would like to set a role permission for displaying a field depending on the value of an other field. But I can't find how to do it.

For example, I have a content type Person. If I add a content Person that is a "policeman" (field Job = "Policeman") then his phone number (field Phone) is display only to user that have the role "Officer". But if the person is a "Secretary" then his phone number is display only to user that have the role "Direction".

Does anyone know how to do it ? Is there a module for that ?

Thanks !
There are 2 modules out there that can do one part of what you're wanting, but not both.


Field Permissions lets you display fields based on role.
Field Formatter Conditions lets you display fields based on the content value of another field.


If your content design is flexible these might help. 

However, if you're looking for field display based on both a role and another field's value you might be better off adding a template_preprocess_node() function to template.php to check for rendering logic. For example:

function MYTHEME_preprocess_node(&amp;$variables) {
  global $user;

  $job = isset($variables['node']-&gt;field_job[LANGUAGE_NONE][0]['value']) ? $variables['node']-&gt;field_job[LANGUAGE_NONE][0]['value'] : '';
  if($job == 'policeman' &amp;&amp; !in_array('Officer', $user-&gt;roles)) {
    hide($variables['content']['field_phone']);
  }
  //@TODO: Add other role/value checks
}