Disabling reply link for comments not working I would like to disable reply to comment for anonymous user. 

I saw on sereval topics that you have to unset 


  $variables['content']['links']['comment']['#links']['comment-reply']


So I ended up adding a preprocess to the .theme file (bartik.theme since I'm using Bartik. Btw I'm using Drupal 8.5.3) 

function bartik_preprocess_comment(&amp;$variables) {
  if (\Drupal::currentUser()-&gt;isAnonymous()) {
    unset($variables['content']['links']['comment']['#links']['comment-reply']);
  }
}


Despite that preprocess, I still have the reply link when I'm anonymous. Does anyone has an idea about what's going on ?
You can use hook_comment_links_alter() rather than THEME_preprocess_comment() .Where as hook_comment_links_alter() will render all the comments links before build:

function YOURMODULE_comment_links_alter(array &amp;$links, Drupal\comment\CommentInterface $entity, array &amp;$context) {
  if (\Drupal::currentUser()-&gt;isAnonymous()) {
    unset($links['comment']['#links']['comment-reply']);
  }
}