function social_comment_remove_author_field in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 8.3 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 8.4 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 8.5 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 8.6 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 8.7 modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 10.3.x modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 10.0.x modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 10.1.x modules/social_features/social_comment/social_comment.module \social_comment_remove_author_field()
- 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');
}
}
}