Allow users to post comments but not to view them

Well, Drupal, you threw me a WTF moment, when on my latest site I gave users the post comments permission, but not the access comments permission, and much to my surprise, users were not able to post comments. I swear this either worked with D5 or there was a module to workaround it. For what it's worth, installing the comment_perm "Comment Permissions" module does NOT help this issue.

Fortunately, for D7 there is a patch, which I reviewed and found to work perfectly.

In the meantime, you can do something similar for D6, but you would be hacking Drupal core. And hacking Drupal core makes pandas sad. Since a happy panda with you makes for a good memory, let's instead hack around this in our template.php in our theme. You can instead do the following below, if you only want those with the 'administer comments' permission to see comments, and if you are comfortable with the comments only being visible in the administration interface (but hey that's what you want right, comments to not be visible, that's why you're here isn't it?)

  1. Open template.php in your current theme, (e.g. if you are using a3_atlantis, then go to sites/all/themes/a3_atlantis/template.php and open it)
  2. Add the following code, replacing a3_atlantis with the name of the theme you are using:
    function a3_atlantis_comment(&$a1, $op) {
      if($op == 'view') {
        if(!user_access('administer comments')) {

This invokes hook_comment, which will override comment viewing. Now, users without 'access comments' permission but with 'post comments' permissions will be able to post comments but not see theirs or any other comment that was posted. If someone has 'administer comments', (e.g., the site adminstrator or you) and wants to be able to view comments the just go to Administer -> Content Management -> Published comments.



Can you help me with a javascript


I think this is good idea. I will try this your example that you give. Thank you.

Add new comment

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.

Comment using an existing account (Google, Twitter, etc.)