Does anyone know a simple way to remove the "homepage" field in the comment form that shows up for anonymous users. I don't understand why this would be a standard option for commenting to ask people for their homepages. But does anyone know a way to remove it, without messing with any of the php code? Thank you.

Comments

jasom’s picture

Same task

WorldFallz’s picture

http://drupal.org/search/node/delete+anonymous+homepage, 3rd link.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

jasom’s picture

Thanks, you again help me. For record:

Add to your tempalte.php:

function phptemplate_comment_form($form) {
   return _phptemplate_callback('comment-form', array('form' => $form));
   
}

and create comment-form.tpl.php:

<?php
//switch off/turn off/disable homepage from comments
  $form['homepage'] = null;
//switch off/turn off/disable comment preview
  $form['preview'] = null;
  print drupal_render($form);
?>

-------------------------
hh, Slovensko plati eurom.

Rhino’s picture

Doesn't seem to work in D6, and this is the only post I find on the topic. Any other pointers?

lvl1’s picture

Will like to know how to do this too. The "Preview" disabling is already there in D6. Could not find anything to disable "Home page" which may be disturbing to users, as most of them dont have own sites.

drupalfan81’s picture

Did you guys find a D6 solution?

narayanis’s picture

What about doing a small module that utilizes drupal_add_js and just hiding the field via simple javascript? It's a little hacky and would still show if a browser has JS turned off (though who does that nowadays?), but you can have a solution in just a couple lines of code.

bsenftner’s picture

You'll need to add this to the appropriate CSS file of your theme:

/* hide the homepage field on the comment forms */
#edit-homepage-wrapper {
  display: none;
}

Note this only works because the homepage field is optional. It's still there, being processed and all. Just not visible on the comment edit form.

Depending upon your expertise level, knowing which CSS file to edit may be another hurdle for you.
This explains some background info you should know before editing a theme's files:
http://www.missingubercartmanual.com/How-to-Customize-a-Drupal-Web-Site
Just read from "Overview of Customizing the Look of Your Site" thru the sub-theming section (about 6 paragraphs.)

And this walks through finding places in a theme's source CSS files, and how to safely modify them in a manner that you can still get updates to your theme (for bug & security fixes):
http://www.missingubercartmanual.com/How-to-Make-Changes-to-a-Drupal-Theme

TmaX-2’s picture

This worked for me on Drupal 6
had to put the code just below the comment section in my style.css file

/* Comments */

/* hide the homepage field on the comment forms */
#edit-homepage-wrapper {
  display: none;

billychan’s picture

Man, you can't pretend to be an expert while offer css solution on this problem. Hiding text by css should always be avoided to the last minute.

bsenftner’s picture

An "expert" knows when a hack is the correct solution for something minor. Time spent on a more sophisticated solution is time wasted that should be spent on something that does matter. So what if an unused, and unwanted field is being processed with no data. Would you prefer a hook_form_alter() solution that most posters would ignore because they are not comfortable writing their own modules? The overhead of a module solution is more expensive in every respect that comes to mind than simply hiding the dumb field...

Michsk’s picture

i do not agree, it starts small with a minor change trough your own module. But eventually your module will have 1000 lines of code because there always will be something you want different or that you don't want to be shown. So it's better to start with your own module then start with one hack and end up using hacks for everything.

billychan’s picture

I just used the solution here and solved my problem perfectly. Not only the "homepage" field, but also all customization in the comment form can be applied.

I bookmarked the link and kept note. Next time I will know how to do. That's better for me.

Pardon me if my word is aggressive. You may be a real expert but we have different points here. I like the idea of separating markup and display, that's where drupal shines. What you mentioned is to mix them, just to get things done. Besides, I never hide text by CSS. I'll try other methods and use JS as last resort though that's rare.

picxelplay’s picture

Old thread but I need to throw in my two cents to point out to novice users how bad this is. CSS hacks are called hacks for a reason. CSS is for cosmetics. Hiding an unused field is not cosmetic. Never ever use css to hide a field; no matter how much faster it is compared to the right way. That should be applied to anything actually. Keeping things separated and done the correct way will help keep a happy healthy Drupal site.

----
Sudo Kill Cylons

Maine’s picture

In case you would like to remove all extra fields (Your name, E-mail and Homepage) from the "Add your comment" form, go to: Administer › Content management › Page (or some other content type), open Comment settings, and in Anonymous commenting radio group select "Anonymous posters may not enter their contact information".

Michsk’s picture

create your own module where you place all this kind of things.

use form_alter() for altering the comment form see; api.drupal.org

Stan.Ezersky’s picture

Add to your template.php

function YOURTHEME_theme() {
    return array('comment_form' => array('arguments' => array('form' => NULL)));
}
 
function YOURTHEME_comment_form($form) {
    unset($form['homepage']);
    return drupal_render($form);
}
rschletty’s picture

The Stan.Ezersky solution worked for me for D6! I do feel better about not using CSS. I get a lot of traffic from malevolent bots. Hopefully this will prevent spam URLs in guest comments.

govindtotla’s picture

I did this by editing my core module. Added these lines just before the output return in module/comment/comment.module function comment_form() .
/* Unset the comment fileds . */

  • unset($form['homepage']);
  • unset($form['mail']);
  • unset($form['preview']);
  • unset($form['admin']['homepage']);

This is just a patch but worked for me.

drupalfan81’s picture

Great thread guys! Thanks for posting! The above code for the template.php file doesn't seem to work for me. Does anyone know how to remove this homepage field from the comment section on Drupal 6?

I would like to completely remove it from outputting to the screen as opposed to just hiding it. The reason for this is because of spam bots.

I had anonymous comment posting available on my site for the past year and only had a very random spam submissions, and thankfully the awesome Mollom module caught these and discarded them. However, I wanted to enable users to be able to anonymous subscribe to their comments. So I enabled this, but I had to turn on the option to allow for anonymous users to leave their email and contact details, which opened up this dumb homepage field.

Literally a day after I enabled this, I received a good 30-40 spam submissions in comments, purely because I had the homepage field listed there and spam bots thought they could get away with posting link backs to their sites. Mollom of course caught all of these and put them in moderation, but now I have to deal with 90 spam comments to delete from the queue. I prefer to have none. My assumption is that if I remove this stupid homepage field (again, no idea why Drupal would have this in their by default), I won't receive these 30-40 comments per day.

I would greatly appreciate the help in removing this homepage field. Thank you in advance!!

drupalfan81’s picture

Hey guys...I found this great writeup, which clearly explains step by step how to remove this annoying homepage field. The correct and easy way with Drupal and using the template.php file.

http://www.digett.com/blog/06/29/2010/how-theme-comment-form-drupal-6

This works, farewell spammers...until the next battle. ;)

vm’s picture

salag’s picture

Can we please update this for drupal 8?

Simply using CSS display: none doesn't work for web crawlers and creates problems because the api inserts the link into the name of the commenter, whether or not they are anonymous.
Where is a good description of how to remove the homepage field programatically?

Thanks.

hilrap’s picture

same here. Searching for a solution in Drupal 8

hilrap’s picture

This code in your NAME_THEME.theme file solved it for me:

function NAME_THEME_form_comment_form_alter(&$form, &$form_state) {
    $form['author']['homepage']['#access'] = FALSE;
}
salag’s picture

Thank you! 

Seems so simple in hindsight, but I just didn't have a firm enough grasp on the new file structure for 8.

tepelena’s picture

Thank you. Worked for me too.

jerome72’s picture

Thank you @hilrap !

serverjohn’s picture

This still works for D9. Thank you! :-)