Look at the function wp_delete_comment()
. It fires an action before the comment is deleted:
/**
* Fires immediately before a comment is deleted from the database.
*
* @since 1.2.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'delete_comment', $comment_id );
… and one after deletion:
/**
* Fires immediately after a comment is deleted from the database.
*
* @since 2.9.0
*
* @param int $comment_id The comment ID.
*/
do_action( 'deleted_comment', $comment_id );
So you can bind your callback to that:
add_action( 'deleted_comment', function( $comment_id ) {
delete_comment_meta( $comment_id, 'your_meta_key' );
} );
Related Posts:
- comment_post_ID 0 (cannot remove from dashboard)
- What for is the table “wp_commentmeta” exactly?
- Resetting comment count
- Would switching to InnoDB from MyISAM improve performance of comments table?
- Can I store my custom comment_type into wp_comments table?
- Using Disqus, how to stop storing comments in wp database?
- What are the additional fields in wp_comments used for?
- migrate comments from old database to new database
- WordPress unresponsive after calling wp_update_comment()
- What is the correct/safe way to delete all comments?
- Recent comments from my blogs only
- How can I get a list of comments by target
- WordPress ‘comment counts’ got messed up, because of a plugin – DISQUS
- delete duplicate comments
- Disable comments on all posts/pages
- Stop WordPress redirecting comment-page-1 to the post page?
- Importing old Disqus comments into WordPress
- How to add a class to the comment submit button?
- Linking to Page Showing Only Comments Without Parent Post
- Comments screen in backend, how to disable email address of commenter for non admins
- How can I limit the number of comments per registered user per day?
- Post Comments using WP REST API v2 in WordPress
- Show content only if member left a comment
- Parent comment’s author name
- get_comments_number of depth-1 (Level 1) (1 post)
- How can I control the comment counts filtering my CPT replies?
- Using filter to add additional fields to comment_form()
- Disable wordpress comments API
- List Recent Comments from Across a Multi-site Network
- Comments waiting but no comments found
- Programmatically block commenting by restricting view of comment form
- Number of External Links in Comments – Moderation Option
- What is comment_karma?
- Comments screen in backend, how to disable Quick Edit | Edit | History | Spam | for non admins
- Get most active users sort by comment count
- Passing arguments to wp_list_comments callback function
- Enable Recent Comments widget to display comments on attachment posts
- Change allowed HTML tags for comments
- comments_template not working correcly in custom template files
- On WordPress 4.4, how to get the post id using the comment_post hook
- How to change style of Disqus comment count on main page
- Adding another arg to comments_popup_link
- Exclude Duplicate Posts in this SELECT Query
- List User Comments on User Profile BuddyPress [closed]
- How to add attributes to the comment form tag?
- How to add replyToUrl schema.org to WordPress comments?
- oEmbed does not work for comments
- Get comments from post and sort by commentmeta value
- Yoast makes comment_reply_link function output plain link to comment instead of reply link
- Problems with comments callback (Argument #1 is not an array?)
- Can WordPress comments have titles and taxonomy?
- Same email for all comments
- Comments system doesn’t like International domains
- Email notification to an email address other than admin for custom type post comments in wordpress
- List comments received by every posts of an specific author
- How do I reply to comments from admin panel on a tablet PC?
- Disable comments for a user? [closed]
- Polls with respective comments?
- Why does akismet prevent jetpack comments from appearing in my moderation queue? [closed]
- Problem with WordPress Comment
- In wp_list_comments comment dates won’t work?
- Where are comment ratings stored?
- Comments change the template name
- I can’t post comment via REST API
- how to SELECT for the current post id?
- WordPress scruity issue – Totally disable all comments by CSS — secure enough?
- wp_new_comment requires author url and author email
- Custom comment link
- How to display the user’s comment status on the front end
- get_comments_number() vs. get_post_field( ‘comment_count’, ID )
- Where are comments coded when using custom theme?
- What is the point of get_comment_count() if you cannot limit by a comment type?
- Wrong IP address in comment section
- Comments turned off, but ‘Leave a reply’ link still there [duplicate]
- How to output number of comments with link to comments
- How do I make Twenty Ten display comments on the home page?
- Sort post comments from newest to oldest in pagination
- Get all comments associated with a specific page ID (comment_post_ID)
- How do I add custom field to Admin comment form and display
- I would like to count number of comments after 5 days ago
- Using Disqus with headless WordPress setup?
- Attaching author tag to the comment
- Delete comments function
- Comment form not working
- How to show a “Comments Are Closed” message on posts where comments have been closed?
- Necessary to have a comments.php if there are no comments?
- Comments pagination on author page
- Comments page id wp_list_comments
- Inserting comments via a procedure
- Can I use WP comments for custom tables?
- How can I have a full comments.php for an easy editing of all its aspects?
- Transfer comments from one domain to another
- WordPress is adding above html
- Passing user meta through comment form
- How do I separate author avatars and comments in 3.4.2?
- How do I convert users who put an email and username for a comment into registered users? [duplicate]
- Function to get a list of all comments on 1 post [closed]
- Display DISQUS on homepage
- How to stop a specific person to comment on my blog? [closed]
- Add ACF Quick Edit Columns on Comments