Need to hide a field for the node author For a particular content type education i need a field to be hidden for the node author. It works in the template file but not with preprocess. This is my code

 function aapka_preprocess_node(&amp;$variables){
     $node = $variables['node'];
     if ($node-&gt;type == 'education'){
     if ($node-&gt;uid == $user-&gt;uid &amp;&amp; $user-&gt;uid != 1) {
 unset($variables['content']['field_college']);}
  }


What am i doing wrong??
You are referencing $user without bringing it into scope.

e.g using your current approach you could do this:

function aapka_preprocess_node(&amp;$variables){
  // Bring global user object into scope
  global $user;
  // Assign by reference
  $node =&amp; $variables['node'];
  if ($node-&gt;type == 'education'){
    if ($node-&gt;uid == $user-&gt;uid &amp;&amp; $user-&gt;uid != 1) {
      unset($variables['content']['field_college']);
    }
  }
}


Keep in mind that won't work if the node is cached and the cache doesn't vary between the author and other regular registered users.