Skip to content

How to Prohibit Comment Deletion

Answer

There is no setting to prohibit comment deletion. Please hide the comment deletion button using styles or scripts.


Overview

Using Styles

You can hide the comment deletion button by configuring the "Styles" as follows.

In this case, all users will be affected.

Style: Hide comment deletion button (Output to: Edit)
comment>.button.delete {
    display: none;
}

Using Scripts

Using "Scripts" allows for more granular control.

For example, by configuring the script as follows, you can prevent users other than specific users from deleting comments.

Script: Prevent users other than specific users from deleting comments (Output to: Edit)
$p.events.on_editor_load = function () {
    // Get the logged-in user's ID
    let loginUserId = $p.userId();
    // User ID allowed to delete comments
    let allowedUserId = 1;
    // If the user ID is not the allowed ID, hide the delete button
    if (loginUserId !== allowedUserId) {
        let deleteButtons = document.querySelectorAll('.button.delete');
        deleteButtons.forEach(function(button) {
            button.style.display = 'none';
        });
    }
};

Manage Table: Styles
Manage Table: Scripts