Remove Homepage Textbox from Comment Form in Drupal 6

In this tutorial, we will look at how to remove the homepage textbox from the default Drupal 6 comment form.

You may want to remove this textbox to clean up the default comment area that Drupal renders out of the box, or you may simply not want users to be able to leave links to their homepage.

Whatever your reason, we will see how to rectify the issue in the tutorial below.

Remove Homepage Textbox from Comment Form Example

Just add the following lines of code to the "template.php" file which should be located in the directory of the theme that you are using. If "template.php" does not exist, simply create it.

You must replace "YOUR-THEME-NAME" in the code below with the name of the theme that you are using.

// sets up the hook we will be using to alter the form
function YOUR-THEME-NAME_theme(&$existing, $type, $theme, $path) 
  $hooks['comment_form'] = array('arguments' => array('form' => NULL));
  return $hooks;
// removes the homepage link from the comment form
function YOUR-THEME-NAME_comment_form($form)
  $output = '';
  unset ($form['homepage']);
  $output .= drupal_render($form);
  return $output;

UPDATE (March 1, 2011): Remember to clear your cache after making any changes to your template.php file!

After you insert the above code in the appropriate file and clear your cache, you should notice that the comment form no longer has the homepage textbox.

We hope this tutorial was useful.

Anders said:

Mar 2, 2011 at 12:59 am

My bad. Hadn't cleared my cache. Works great!!

vincent said:

Mar 2, 2011 at 9:33 am

Glad I could help..!

Anders said:

Feb 28, 2011 at 8:00 am

Just what I was looking for, but doesn't work for me. After inserting the code, the comment form is unchanged.

vincent said:

Mar 2, 2011 at 12:11 am

Ensure that you have inserted your theme name in the code as per the instructions. Remember to clear your cache after you make the changes! Post back here if you need more help...

Anonymous said:

Dec 7, 2011 at 11:29 pm

I already have the MY_Theme_Name declared in the template file. The system will not allow more than declaration of the function name.

vincent said:

Dec 8, 2011 at 12:06 am

That is not a problem. Just append the additional code to the code which already exists inside of the declaration of the function.

You don't need a separate function with the same name :-)

Thank Tutorial Arena for This Tutorial.
Show your appreciation with a +1...