How can I prevent a form from being displayed in the privatemsg module? I am trying to remove the "Block a user" fieldset, username text and input field, and "Block user" button from the "Blocked users" page as shown below.



The code I'm trying to change is in the pm_block_user module:

/**
 * Formbuilder function to build a simple form to block users.
 */
function pm_block_user_list() {
  global $user;
  $form['new'] = array(
    '#type'   =&gt; 'fieldset',
    '#title'  =&gt; t('Block a user'),
  );
  $form['new']['name'] = array(
    '#type' =&gt; 'textfield',
    '#title' =&gt; t('Username'),
    '#autocomplete_path' =&gt; 'messages/user/autocomplete',
    '#description'        =&gt; t('Separate multiple names with commas.'),
    '#required'          =&gt; TRUE,
  );
  $form['new']['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Block user'),
    '#validate' =&gt; array('pm_block_user_block_validate'),
    '#submit' =&gt; array('pm_block_user_block_submit'),
  );

  $header = array(
    array(
      'data' =&gt; t('Username'),
      'field' =&gt; 'u.name',
      'sort'  =&gt; 'asc',
      ),
    array(
      'data' =&gt; t('Operations'),
      ),
  );

  $select = db_select('pm_block_user', 'pmb')-&gt;extend('PagerDefault')-&gt;extend('TableSort')
    -&gt;fields('pmb', array('author'))
    -&gt;condition('pmb.recipient', $user-&gt;uid)
    -&gt;limit(20)
    -&gt;orderByHeader($header);

  // Only show existing users, therefore join users.
  $select-&gt;innerJoin('users', 'u', 'u.uid = pmb.author');

  $rows = array();
  foreach ($select-&gt;execute() as $row) {
    $rows[] = array(
      theme('username', array('account' =&gt; user_load($row-&gt;author))),
      l(t('unblock'), 'messages/block/' . $row-&gt;author, array('query' =&gt; drupal_get_destination())),
    );
  }
  $form['#header'] = $header;
  $form['#rows'] = $rows;
  return $form;
}


Here is the code I tried in my template.php based on these instructions for removing unwanted elements from forms:

function MYMODULE_pm_block_user_list($form) {
  unset($form['new']['#title']);
  unset($form['new']['#type']);
  return drupal_render($form);
}


However, this code hides the "Username/Tom/Operations/unblock" section, not the "Block a user" section which I am trying to hide.
The following code does it for me:

function MYMODULE_form_pm_block_user_list_alter(&amp;$form, &amp;$form_state, $form_id) {
  unset($form['new']);
}


This should help if you didn't know about it.  

hook_form_FORM_ID_alter();

Also there's the more generic hook_form_alter().