I'm using Drupal 8 for a personal project and I'd like to allow only the node author to post comments.

Can you please help? I'm stuck.

  • Hi Alessio, do you use a custom theme or you're using a default theme ?
    – Yuseferi
    May 14, 2020 at 14:34
  • Hi Yusef, I made a custom theme based on bootstrap. May 16, 2020 at 11:45
  • have you checked my latest changes?
    – Yuseferi
    May 22, 2020 at 16:11

1 Answer 1


although the Drupal 8 version still is on dev but you can try comment_perm module.

The Comment Permissions module enables control of commenting by user role and by node type. Additional user permissions for selected node types are added to the user access system so you can configure commenting with more control than Drupal core provides.


another solution that I could suggest is using hook_form_alter.

in your custom module

function YOURMODULENAME_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  if($form_id == "YOUR_COMMENT_TYPE_ID"){
    $node = \Drupal::request()->attributes->get('node');
    if(!is_null($node) && $node->getOwnerId() != \Drupal::currentUser()->id()) {
      $form['#access'] = false;


  • Hello, I've tried the comment_perm module for Drupal 8, but after installing it I can't find a permmission like " only the author of the node can make comments to the node" . I read the instructions and they say to configure the module going to Administration >> Configuration >> Comment permissions , but there is nothing to configure. May be the 8.x version is only for development? May 15, 2020 at 13:57
  • @AlessioPellegrini I've updated my answer. try it and let me know if you need more details.
    – Yuseferi
    May 17, 2020 at 13:46
  • I'm sorry but I've just noticed your answer, thank you for your reply. I'm trying to understand why I don't get notifications from this site when someone answers me. I`m going to try. Jun 17, 2020 at 19:00
  • @AlessioPellegrini no worries. let me know about the result ;)
    – Yuseferi
    Jun 18, 2020 at 10:09
  • Ok, I made a clean D8 install and created a custom module ( hello_world ), in the hello_world directory I`ve created hello_world.info.yml and hello_world.module . In the hello_word.module I inserted this code: [code]<?php function hello_world_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { if($form_id == "comment"){ if($form['#node']->getOwner()->id() != \Drupal::currentUser()->id()){ // disable form $form['#access'] = false; } } } [/code] and after clearing the cache I tried, but common users can still comment on other users' articles Jun 18, 2020 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.