You are here

function social_comment_remove_author_field in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  2. 8.3 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  3. 8.4 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  4. 8.5 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  5. 8.6 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  6. 8.7 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  7. 10.3.x modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  8. 10.0.x modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  9. 10.1.x modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
  10. 10.2.x modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()

Removes the author fields and replaces the status field for comment forms.

Parameters

array $form: The form that needs to be processed.

bool $add_status: Add the status field, by default TRUE.

1 call to social_comment_remove_author_field()
social_comment_form_comment_form_alter in modules/social_features/social_comment/social_comment.module
Implements hook_form_FORM_ID_alter().

File

modules/social_features/social_comment/social_comment.module, line 122
The Social comment module.

Code

function social_comment_remove_author_field(array &$form, $add_status = TRUE) {

  // Check if we need to hide the author fields for comments.
  $remove_author_fields = \Drupal::config('social_comment.comment_settings')
    ->get('remove_author_field');
  if ($remove_author_fields) {

    // Remove access to author fields.
    unset($form['author']['#title']);
    $form['author']['uid']['#access'] = FALSE;
    $form['author']['name']['#access'] = FALSE;
    $form['author']['mail']['#access'] = FALSE;
    $form['author']['homepage']['#access'] = FALSE;
    $form['author']['date']['#access'] = FALSE;

    // Make the status field consistent with other status fields.
    if ($add_status) {
      $form['author']['status']['#type'] = 'checkbox';
      $form['author']['status']['#title'] = t('Published');
      $form['author']['status']['#access'] = \Drupal::currentUser()
        ->hasPermission('administer comments');
    }
  }
}