Akismet plugin is deleting spam despite preferences

Curiously, Akismet is deleting old spam comments after a period of time (I’m guessing within a week).

This box is NOT checked:

Read More

Auto-delete spam submitted on posts more than a month old.

I’ve sent a message to Akismet support more than a week ago but I’ve not yet received a reply.

I do not want Akismet to delete anything. I do not check often enough to verify false positives so I want all comments saved indefinitely, even the spam.

Does anyone know why it’s deleting spam comments even though it’s set not to? Does anyone know of a workaround?

Related posts

Leave a Reply

2 comments

  1. I would generally not recommend modifying files for Plugins that you do not control. Better would be to write your own site/custom Plugin, to control this hook:

    add_action('akismet_scheduled_delete', 'akismet_delete_old');
    

    First, to stop the deletion altogether, simply call:

    remove_action('akismet_scheduled_delete', 'akismet_delete_old');
    

    Then, you can set up a cron job (or similar), to fire the akismet_delete_old() function on whatever frequency you prefer.

    Edit

    To be more clear: I’m referring to a site/custom Plugin, that interacts with Akismet – not a fork/replacement of Akismet. Since Akismet adds the comment-deletion functionality as a callback to an action hook specific to the Plugin, you can override that added action from outside the Plugin.

    The remove_action() call above will simply stop the comment-deletion code from running at all. If you want to enable less-frequent comment deletion, you could use several methods:

    1. Rewrite the akismet_delete_old() callback (as you have done in your own answer), and then hook it into akismet_scheduled_delete
    2. Write your own cron job to run on your desired frequency
    3. Etc.

    Note: there is a companion callback, akismet_delete_old_meta(), that you may need to modify/remove from the akismet_scheduled_delete action, also.

  2. Firstly, there is no setting for not deleting spam comments. My confusion was caused by ambiguous wording on the Akismet configuration page…

    Auto-delete spam submitted on posts more than a month old.

    “more than a month old” is referring to “posts” that are more than a month old, not “spam submitted on posts” that are more than a month old.

    As far as the original question about how to stop the comments from being deleted…

    They are automatically deleted after 15 days, no matter what. Akismet thinks they know best! They assume you want the spam deleted after 2 weeks because they also assume that 15 days is more than enough time for you to verify that the comment was flagged correctly.

    I asked them why they couldn’t simply give the user an option and I got some excuse about how thousands of spam comments can shut down a server. Fine, that’s true. But the same thing could happen if the Akismet plugin wasn’t installed in the first place. Give the admin a little credit for being able to make his own decision regarding his installation. But that’s not going to happen.


    I realize editing core files is frowned upon, but here’s how I decided to handle it for my own site.

    This line in the wp-content/plugins/akismet/akismet.php file…

    $comment_ids = $wpdb->get_col("SELECT comment_id FROM $wpdb->comments WHERE
    DATE_SUB('$now_gmt', INTERVAL 15 DAY) > comment_date_gmt AND
    comment_approved = 'spam'");
    

    I edited INTERVAL 15 DAY to 180 days, giving me more than enough time to review comments before deletion.

    EDIT:

    Every time the plugin is updated, such a modification would have to be re-applied.


    EDIT 2:

    As per helpful suggestion by @ChipBennett, I created a plugin which does nothing but deactivate the comment deletion by Akismet plugin. This simple thing avoids the whole issue of having to modify the Akismet plugin.

    I simply created the following php file and put it in the plugins directory (wp-content/plugins/)

    <?php
    /**
     * @package Akismet_keep_comment
     * @version 1.0
     */
    /*
    Plugin Name: Akismet Keep Comment
    Plugin URI: 
    Description: This plugin removes the comment deletion ability of the Akismet plugin
    Author: Me
    Version: 1.0
    Author URI: http://www.mysite.com
    */
    
    remove_action('akismet_scheduled_delete', 'akismet_delete_old');
    
    ?>
    

    Then I “activated” it via the plugin page of the Dashboard.