Score:0

How to restrict access to comment form and posted comments for certain users

kr flag

I have a content type where comments are enabled. So on node view, I can see the comment form and all the posted comments.

Is it possible to not display the comment form and all the posted comments for a user? i-e

if ($current_user_id === $target_id) {
  // Hide comment form and posted comments
}

I have checked the CommentAccessControlHandler class and the method checkCreateAccess but that function is not called on node view I think.

How can I do that?

miststudent2011 avatar
fr flag
One quick way is to create new role and add required comment related permission to that role. Assign that role to all the users except to the user for whom you wish to restrict access
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.