How to allow posting replies to comments to certain user roles only?
The goal is to allow users to post comments but not reply to them and have only certain roles able to post replies.

Initially I thought of hiding reply link for certain roles. But it is not a very bullet proof solution. Anyone knows of better methods?

  • I was browsing your profile and found this interesting un-accepted question. PS: awesome website btw.
    – No Sssweat
    Mar 18, 2016 at 23:46
  • @NoSssweat thank you. It's nice to have web content that represents your own style and preference. simple works for me
    – oksana-c
    Mar 19, 2016 at 13:36

3 Answers 3


Edit your comments.tpl.php file and delete the <?php print render($content['links']) ?>

Then all you gotta do is create your own reply, edit, and delete links

  • reply is /comment/reply/[nid]/[cid]
  • edit is /comment/[cid]/edit
  • delete is /comment/[cid]/delete

So use PHP to load the nid and cid and replace the [tokens] with your PHP code.

Then use PHP if statement to check whether login (global) user is of role x, if true, you print the reply link.

For edit and delete links, you check if login (global) user uid is the same as comment author uid.

  • 1
    Your solution will work, but it doesn't cover the scenario to where user accesses the reply URL directly. My preference is to not place such logic in template files. I should have answered my own question a while ago. I added a new permission to "Comment Permissions" module (already use it). The permission is called "Reply to Comments" and can be set specifically for the content type. Works great and covers the loophole with direct access to reply URL. Havent had a chance to submit a patch yet, but planning on it. Thank you for putting your time towards addressing this issue.
    – oksana-c
    Mar 19, 2016 at 13:39

You could look at this module. It has more control on comments permission than what Drupal core does.

Another method is to add some code using hook_alter

MODULENAME_form_alter(&$form, &$form_state, $form_id) {
if ( $form_id == 'comment_form') {
  global $user;
  if(//certain role)
     unset(//comment reply form);
  • Thank you for ideas! The "Comment Permissions" module that you mentioned is a great improvement for permission control, but it does not provide permission to Reply that I need. Comment_reply form has the same form ID as normal comment form (ID = "comment-form"), so if I unset "comment_form" for a role - it will remove not only the reply form but also comment form, which is not what I need. Also, it is possible to remove form fields with unset (), not the whole form... or am I missing something?
    – oksana-c
    Jan 18, 2016 at 11:27

For a more robust solution, create a RouteSubscriber to take over the comment.reply route and provide your own controller.

Your controller can extend CommentController from the comment module in core and either just replace the replyFormAccess function, or call the parent first and then build on it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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