WordPress action hook · part of WordPress core

delete_comment

A WordPress core action that 6 plugins also fire themselves, running on 6M+ sites between them.

How to use delete_comment

It's an action: your callback runs at that point and receives 1 argument. Nothing needs to be returned. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_action( 'delete_comment', function( $comment_ids ) {
	// Your code runs here.
}, 10, 1 );

Argument names come from Drainware Comments Filter's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

6 plugins that fire delete_comment

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Akismet Anti-spam: Spam Protection icon Akismet Anti-spam: Spam Protection5+ million installs do_action( 'delete_comment', $comment_id, $comments[ $comment_id ] ) class.akismet.php:889
  2. ManageWP Worker icon ManageWP Worker1+ million installs do_action( 'delete_comment', $comment->comment_ID ) functions.php:238
  3. Drainware Comments Filter icon Drainware Comments Filter10+ installs do_action( 'delete_comment', $comment_ids ) drainware.php:424
  4. Spam Catharsis icon Spam Catharsis10+ installs do_action( 'delete_comment', $comment_ids ) spam_catharsis.php:60
  5. Migrate Xcart to WooCommerce icon Migrate Xcart to WooCommerceFewer than 10 installs do_action( 'delete_comment', function($comment_id ) { global $wpdb, $table_prefix; $format = array( '%d', '%s' ); $wpdb->delete( $table_prefix.'xcart_relation', array( 'wp_id' => $comment_id, 'term' => 'comment' ), $format ); $weightArray = array( 'status' => 0 ); $where = array( 'term' => 'reviews' ); $format = array( '%d' ); $whereFormat = array( '%s' ); global $wpdb, $table_prefix; $wpdb->update($table_prefix.'xcart_ope... ) woo-xcart-migration.php:1039
  6. Spam Oborona YandexCleanWeb icon Spam Oborona YandexCleanWebFewer than 10 installs do_action( 'delete_comment', $comment_ids ) inc/core-class.php:564

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.