How do I hide fields conditionally? i made my own module in my drupal 7 website to hide a boolean when its value is "0"
but something won't work

this is the code

   function MYTHEME_node_view($node, $view_mode, $langcode) {
if($node-&gt;content['field_members_only']['#items']['0']['value']=="0") {
                      hide($node-&gt;content['field_members_only']); 
                    }
}


what's wrong?
i think the conditional part is wrong
if i save the statement without the IF part it's working perfectly

thanks
You need to set access to FALSE.

function MYTHEME_node_view($node, $view_mode, $langcode) {
  if(isset($node-&gt;content['field_members_only']) &amp;&amp; count($node-&gt;content['field_members_only']) &amp;&amp; $node-&gt;content['field_members_only']['#items']['0']['value']=="0") {
    $node-&gt;content['field_members_only']['#access'] = FALSE;
  }
}