Hide "Your name" field in comment form from everyone except admin What I want to achieve is to hide the "Your name" field in comment form from all anonymous and authenticated users but visible to users with the admin role.

I was able to use CSS to hide the field, but it also hides from admin.

Please is there a way to selectively hide the field to anonymous and authenticated users but not to administrators?
function YOURMODULE_form_comment_form_alter(&amp;$form, &amp;$form_state) {
  global $user;

  if ($user-&gt;uid != 1) {
    unset($form['author']['name']);
  }

}


Another way is, if your theme has a comment.tpl.php file, putting a condition to restrict authenticated and anonymous user.

&lt;?php print $author; ?&gt; 


To limit this to a particular content type, you can create a separate comment template file for that content type.