I have what I believe is a slightly unusual requirement for comments. I'm trying to figure out how to implement this:

  1. Comment form should always appear at the bottom of the page (this helps users understand they can submit a comment especially if there are no comments yet for a given article)
  2. If the user is registered the comment form should be enabled.
  3. If the user is anonymous the comment form should be disabled and provide a link to registration

It seems like the comment module is generally built to be on or off. Any recommendations on exposing it as a disabled form?

1 Answer 1


I didn't know this until I just tried it but you can use a hook_form_alter() function in a custom module and simply set the whole $form to disabled...this disables all child elements as well. Combine it with the user_is_anonymous() function and you should be set:

function MYMODULE_form_comment_form_alter(&$form, &$form_state, $form_id) {
  if (user_is_anonymous()) {
    $form['#disabled'] = TRUE;
    // Add a link:
    $form['register_link'] = array(
      '#markup' => l('Click here to register...', 'user/register')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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