Curiously, Akismet is deleting old spam comments after a period of time (I’m guessing within a week).
This box is NOT checked:
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?
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:
First, to stop the deletion altogether, simply call:
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:akismet_delete_old()
callback (as you have done in your own answer), and then hook it intoakismet_scheduled_delete
Note: there is a companion callback,
akismet_delete_old_meta()
, that you may need to modify/remove from theakismet_scheduled_delete
action, also.Firstly, there is no setting for not deleting spam comments. My confusion was caused by ambiguous wording on the Akismet configuration page…
“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…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/
)Then I “activated” it via the plugin page of the Dashboard.