You are here

function comment_og_form_alter in Comment OG 5

Same name and namespace in other branches
  1. 6 comment_og.module \comment_og_form_alter()

Implementation of hook_form_alter().

File

./comment_og.module, line 44

Code

function comment_og_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'comment_form' && isset($form['nid'])) {

    // if this is group context and you're not a member of this group, disable the comment form
    if (!og_is_group_member(og_get_group_context())) {
      $form['comment_filter']['comment'] = array(
        '#type' => 'textarea',
        '#title' => t('Comment'),
        '#rows' => 5,
        '#disabled' => TRUE,
        '#description' => t('You must be a member of this group in order to post a comment.'),
      );
      if (isset($form['subject'])) {
        unset($form['subject']);
      }
      if (isset($form['comment_filter']['format'])) {
        unset($form['comment_filter']['format']);
      }
      if (isset($form['submit'])) {
        unset($form['submit']);
      }
      if (isset($form['preview'])) {
        unset($form['preview']);
      }
      if (isset($form['author'])) {
        unset($form['author']);
      }
      if (isset($form['_author'])) {
        unset($form['_author']);
      }
    }
  }
}