0

What I am trying to do is create a list of IP addresses each time I click Spam on a comment. The only issue I have now is, how do I get the commentors IP address inside this function.

This is what I am working with... It ties into the onclick event of the Spam button.

add_action('transition_comment_status', 'report_spam', 1);
function report_spam($new_status){
    if($new_status == 'spam'){
        //do something here with IP
    } 
}
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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