Docs & Support

Learn about all the Formidable features and get support from our amazing customer success team.

frm_spam_retention_days

Heads up! This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or third-party development.

Use the frm_spam_retention_days filter to change how many days spam entries are kept before Formidable deletes them. It overrides the Delete spam entries automatically setting in the Captcha/Spam global settings.

Formidable Forms Pro checks for old spam entries once a day. Spam entries older than the period are permanently deleted.

Requirements

  • Formidable Forms 7.0 or later, with Formidable Forms Pro 7.0 or later active on a Basic, Plus, Business, or Elite license.

Formidable Forms makes advanced site building simple. Launch forms, directories, dashboards, and custom WordPress apps faster than ever before.

How it works

The Delete spam entries automatically setting in Formidable → Global Settings → Captcha/Spam offers Never, or a period of 7, 15, 30, 60, or 90 days. The default is 30 days.

  • The cleanup runs on Formidable's daily scheduled event, frm_daily_event. It deletes up to 500 spam entries at a time, and continues a minute later when there are more.
  • Spam entries are aged from when they were submitted. An entry someone marked as spam is aged from when it was marked. A marked entry with no saved mark date is kept.
  • Entries are deleted the same way as deleting them from the entries list. Hooks such as frm_before_destroy_entry run for each one.

Usage

add_filter( 'frm_spam_retention_days', 'my_function_name', 20 );

Parameters

  • $days (int): The number of days to keep spam entries. By default, it's the saved setting. Return 0 to keep spam entries until someone deletes them. Any whole number of days works, not only the setting's choices.

Examples

Learn where to put the code when adding a custom PHP function to your site.

Keep spam entries for 14 days

This example deletes spam entries after 14 days. The second line shows the same period in each form's Spam settings.

add_filter( 'frm_spam_retention_days', 'my_frm_spam_retention', 20 );
add_filter( 'frm_spam_retention_summary', 'my_frm_spam_retention', 20 );
function my_frm_spam_retention( $days ) {
	return 14; // Keep spam entries for 14 days.
}

Keep spam entries on a staging site

This example turns off spam cleanup on a site whose environment type is staging.

add_filter( 'frm_spam_retention_days', 'my_frm_keep_spam_on_staging', 20 );
function my_frm_keep_spam_on_staging( $days ) {
	if ( 'staging' === wp_get_environment_type() ) {
		return 0;
	}
	return $days;
}

Limitations

  • The Delete spam entries automatically setting still shows the saved choice. To show your period in each form's Spam settings, use the frm_spam_retention_summary filter.
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2026 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.

    Complete your purchase
    Don't forget your purchase!
    Complete Purchase
    Join 400,000+ using Formidable Forms to create form-focused solutions fast. Get Formidable Forms