2

I made it mandatory for anonymous users to leave contact information while commenting along with comment notify so as to improve the user engagement. There are two problems that crept in because of this:

  1. A homepage field also got added with the email field. I want to remove only the homepage field, leaving the email field in place. I could not figure out how to do this.

  2. People comment with fake email addresses.

Can anybody tell me a workaround for these problems?

7

If you wish to allow anonymous comments but remove the Homepage field, you can do so in either a custom module or theme function that implements hook_form_FORM_alter().

Via a theme function (source, mengi on drupal.org):

function THEME_form_comment_form_alter(&$form) {
  $form['author']['homepage']['#access'] = FALSE;
}

Or via a custom module:

function MYMODULE_form_comment_form_alter(&$form) {
  $form['author']['homepage']['#access'] = FALSE;
}

Note: Anonymous comments may be reasonable if you use other anti-spam measures such as honeypot fields and javascript-filled anti-spam fields.

| improve this answer | |
  • 1
    Just to note this solution still works in D8. Though I'm curious what's necessary to stop the Homepage field appearing in the first place - it's still there for me if anonymous users have zero comments permissions (including Post Comments) – William Turrell Jun 26 '18 at 13:18
1

You can change which fields appear on the comment for at:

/admin/structure/types/manage/YOUR_CONTENT_TYPE/comment/fields

The easiest way to cut out fake email addresses would be to get users to register before they are allowed to comment and have check the Require e-mail verification when a visitor creates an account. option.

| improve this answer | |
  • The path you gave has only 2 fields: comment_body and comment_notify_settings . None of these show settings to modify the fields that anonymous users will have to fill for leaving contact information while commenting. Asking a user to register to just comment on a post does not sound a very good idea to me. Is there a way to achieve both simultaneously? – Rana Prathap Mar 28 '14 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.