Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

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?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
The placeholder was how I was leaning. I hadn't actually thought to ask the user why they were deleting. A topical placeholder is almost perfect. –  cMFG Apr 3 '13 at 8:50
    
You mentioned the comments meta and it got me thinking about cleanup of my plugin. If the user uninstalls my plugin should I delete all of the associated custom posts and comments? Sorry if this is way off topic but I was wondering if I should use a custom table instead of polluting the commentsmeta table. –  cMFG Apr 3 '13 at 8:51
    
@cMFG Tricky question. Try a separate button to delete these data on demand. –  toscho Apr 3 '13 at 8:54
    
Well this is more of a user expectation issue. If a user clicks uninstall they expect the plugin to be gone. It seems likely that any 'required' step before uninstallation would be ignored by most users, so doing such tasks in the uninstall hook would be better, right? –  cMFG Apr 3 '13 at 8:57
    
The problem is rather the max execution time. Try to clean up one million comments in an uninstall hook. –  toscho Apr 3 '13 at 8:58
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.