How to hide a field by role? i have the CCK Perm but i dont know how to hide it using the contemplate.

Comments

polmaresma’s picture

I have the same problem, I wanna hide a cck field to anonymous users....

Some response?

thank's

realityloop’s picture

Status: Active » Closed (fixed)

Anonymous users have ID of 0 so the following returns false and hides content.

global $user;
if ($user->uid){

[the bit you want to hide]
};

jjeff’s picture

global $user;
if (in_array('name of role', $user->roles)) {
   print $node->field_my_field['view'];
}

Untested code off the top of my head, but you get the general gist.