How to remove Input format from comment form? I used following code to create a module to remove input format from comment forms, but it doesn't work. Is there anything I'm missing or another way to do this ?

&lt;?php
function comment_custom_form_alter($form, $form_state, $form_id) {
  if ($form_id == 'comment_form') {
    foreach ($form['comment_filter']['format'] as $i =&gt; $filter) {
      if (is_int($i) &amp;&amp; !$filter['#type']) {
        $form['comment_filter']['format'][$i]['#value'] = '';
        $form['comment_filter']['format'] = '';
        unset($form['preview']);
        unset($form['_author']);
      }
    }
  }
}
?&gt;
Administer &gt; Site Configuration &gt; Input Formats


Click configure for each of the formats, and edit which roles can see which format.

You can also look at Better Formats.


  Set the default format per role. Set the default format per content
  type. Control allowed formats per content type. Hide format tips. Hide
  more format tips link. Hide format selection for nodes, comments, and
  blocks seperately, forcing the default to be used. Expand the
  selection fieldset by default. Disable the expand/collapse of the
  selection fieldset. Set selection fieldset title. Set more format tips
  link text. Set default formats for nodes and comments separately.
  Sensible defaults and fail overs for ease of use. Works with CCK
  textareas. Works with Panels comment form. i18n module support for
  user defined strings


.

Also if you want to hide it completely you can also unset the filter form element in your form alter but I don't think it is the right way to do it.

unset($form['comment_filter']['format']);


NOTE: If you do so you will loose out on text processing and checks which drupal makes to make sure the html is safe.

This should also work

$form['comment_filter']['format']['#access'] = FALSE;


This will make sure the format is not accessing to anyone.



Try this

function modulename_form_alter(&amp;$form, &amp;$form_state, $form_id) {
 if ($form_id == 'comment_form') {
  $form['comment_filter']['format']['#access'] = FALSE;
 }
}