Unless you’re passing $force_delete
as true
when calling wp_delete_comment()
, the delete_comment
hook doesn’t fire. This is because WordPress calls wp_trash_comment()
at the beginning of wp_delete_comment()
if $force_delete
isn’t set true
.
Try hooking into the trash_comment
action hook:
function _dbdb_delete_comment( $comment_id ){
$filter = current_filter();
var_dump( $filter );
var_dump( $comment_id );
wp_die( __FUNCTION__ );
}
add_action('delete_comment', '_dbdb_delete_comment' );
add_action('trash_comment', '_dbdb_delete_comment' );
I added that to my theme’s functions file and checked my network response tab in Chrome Dev tools. I tested by deleting (trashing) a comment through the Comments screen in the Admin. It worked as expected.
The filter that was returned was trash_comment
.