Created
July 7, 2020 10:53
-
-
Save skounis/78247e173562ab930a271c018cab78e3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fut_content_preprocess_field(&$variables) { | |
$element = $variables['element']; | |
if ($element['#field_type'] == 'comment') { | |
if (_fut_content_prevent_comments()) { | |
unset($variables['comment_form']); | |
} | |
} | |
} | |
function fut_content_comment_links_alter(array &$links, CommentInterface $entity, array &$context) { | |
if (_fut_content_prevent_comments()) { | |
unset($links["comment"]["#links"]["comment-reply"]); | |
} | |
} | |
function _fut_content_prevent_comments() { | |
$current_user = \Drupal::currentUser(); | |
$group = \Drupal::service('fut_group.request_entity_extractor')->getGroup(); | |
$prevent = isset($group) && !$group->hasPermission('comment group content', $current_user); | |
return $prevent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment