You are missing 2 parameters in your function report_spam
. Also the priority should not be 1. Try the code below.
add_action('transition_comment_status', 'report_spam', 10, 3);
function report_spam($new_status, $old_status, $comment){
if($new_status == 'spam'){
var_dump($comment->comment_author_IP);
die;
}
}
I’ve set die
so that you can check and manipulate what you want.