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:
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:
- Rewrite the
akismet_delete_old()
callback (as you have done in your own answer), and then hook it into akismet_scheduled_delete
- Write your own cron job to run on your desired frequency
- 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.