How to hide rating field when adding comment to own node?
You should use unset($form['field_stars']); instead of $form['field_stars']['#access'] = 0; 

You can keep the fields as required and also remove the else condition.

So your final code would be something like this

function hiderating_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  global $user;
  if ($form_id == "comment_node_stuff_form") {
   if ($form['#node']-&gt;uid == $user-&gt;uid) {
      unset($form['field_stars']);
      }
    }
}