I'm using Drupal 7. I'm trying to add comments to a node but I get this error back:"You are not authorized to post comments". I can't find in the code which variables are being checked to don't allow me to post a comment. Can someone tell me where to look in the code? Thank you very much


Go to: admin/people/permissions

Check de permission:

  • Post comments

Click button "save permission".


You might be looking for the comment_access() function.

Determines whether the current user has access to a particular comment.

There's not much to it:

function comment_access($op, $comment) {
  global $user;

  if ($op == 'edit') {
    return ($user->uid && $user->uid == $comment->uid && $comment->status == COMMENT_PUBLISHED && user_access('edit own comments')) || user_access('administer comments');

If you have not already checked, go to People>Permissions>Comments.

  • It is checked, thanks. The thing is that I want to know where in the code the comments system checks the permissions variables: user->id, global['user'], etc... – damargon Nov 2 '17 at 19:41

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.