Plugin: How should I handle deleting comments?

I am writing a plugin that creates an api for a custom post type.

Users can comments on the custom post types and the comments are added using WP core comment methods.

Read More

My question arises when trying to deal with what to do when deleting a comment.
I understand what methods to use, but my question is more about the general procedure.

When you make a comment it can be a reply to another comment. If the parent commenter decides to delete their comment, what should be done with replies? Should they be deleted as well?

Should their parent pointer just move one up the tree?

You could also replace the deleted comment content with a message like, ‘Comment deleted’. Like a placeholder. Then the replies could keep the same parent pointer, but they would lose the context of the original parent comment’s content.

Am I overthinking this?

Related posts

Leave a Reply

1 comment

  1. Do not delete the comment. One comment could have multiple children, and moving the replies up would create a false impression in any case.

    The real question here is why someone wants to delete a comment and how you could react:

    • The content is obsolete or wrong: Add a note, mark it as outdated.
    • The commenter disclosed something secret: Replace the comment content with a note.
    • The commenter doesn’t want to be seen on the site anymore: replace the commenter name with anonymous.

    In any case, I would require a reason for deletion request, and create a separate comment review queue. Use comment meta fields for that.