Hide comments for unauthorized users

Hello,

I would like to prevent some users to see the comments and comment themselves.

They will use the email to communicate and the comments will be only used as a kind of intern chat for technicians.

Do you have any idea of the right way to manage to do that ?

Comments seem to be always accessible, regardless of the permission manager.
It would be easy if I could just tell which role can or cannot get access, but it is not working.

Another possiblity would be to add a function to modify the CSS related to the comments to hide them for certain users, but css can be easily modified by the end user so it is kind of pointless.

reasonable requirement,

I am currently trying a third method with the .hide or the .hidden but without any real success right now.

Hello,

I can hide() or remove() the whole class “new-timeline” element or the class “timeline-items” elements, but even when the child element is correctly selected with a data-doctype filter, I can’t remove it with a removeChild().

Do you have any idea of the reason and how to force the removal ?

To anyone interested to enable such a feature, here is how I finally managed to completely remove every comments (and only comments) of the timeline for a specific role :

if (!frappe.user.has_role(“XXXXX”)){
document.querySelectorAll(‘.timeline-item[data-doctype=Comment]’).forEach(comment => comment.remove());
}

1 Like