New function that would activate after marking a comment as spam

  1. lelkoun


    Hello. I am the author of a plugin called "Spammer Blocker". It blocks every visitor who posted a comment that was later marked as spam. The problem is, that when you remove spam comments, you also remove all IP addresses.

    So I decided to fix this in the next version of the plugin. I want to store all IP addresses in another table, so the records cannot be deleted.

    But to do that, I need to copy an IP address immediately after a comment is marked as spam. There is one way how to do it - using a trigger in MySQL database. But not all webhosts allow using triggers, so I need an alternative.

    Can you add a new function for this action?
    Thanks. :)

    Posted: 7 years ago #
  2. Justin Tadlock
    WordPress God

    Look in wp-includes/comment.php. There are multiple hooks to work with. Take a special note of the hooks available in the wp_transition_comment_status() function.

    Posted: 7 years ago #
  3. lelkoun


    Thank you for your reply.

    I just do not know how can I get the author's IP address. Could you help me, please?

    function sb_copy_ip($new_status){
    //now I need to find out the comment ID to copy it's author IP address
    do_action('transition_comment_status', $new_status);
    add_action('transition_comment_status', 'sb_copy_ip', 1);
    Posted: 7 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    4 Votes
  • Status

    This is plugin territory

No tags yet.