Same name and namespace in other branches
  1. 4.7.x modules/comment.module \comment_access()
  2. 5.x modules/comment/comment.module \comment_access()
  3. 6.x modules/comment/comment.module \comment_access()
  4. 7.x modules/comment/comment.module \comment_access()

This is *not* a hook_access() implementation. This function is called to determine whether the current user has access to a particular comment.

Authenticated users can edit their comments as long they have not been replied to. This prevents people from changing or revising their statements based on the replies their posts got. Furthermore, users can't reply to their own comments and are encouraged instead to extend their original comment.

File

modules/comment.module, line 344
Enables users to comment on published content.

Code

function comment_access($op, $comment) {
  global $user;
  if ($op == 'edit') {
    return $user->uid && $user->uid == $comment->uid && comment_num_replies($comment->cid) == 0;
  }
}