Docs & Support

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

frm_exclude_spam_entries

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_exclude_spam_entries filter to include spam entries in an entry query that normally leaves them out. Return false to keep spam entries in the results.

Spam entries are saved so they can be reviewed in the Spam tab of the entries list. Everywhere else, Formidable leaves them out of entry queries, such as entry counts, Views, graphs, and exports.

Requirements

  • Formidable Forms 7.0 or later. The hook is part of Formidable Forms Lite.

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

When it runs

The filter runs when Formidable builds an entry query that doesn't already choose an entry status. In Formidable Forms Lite, queries that filter by status, such as the one behind the Spam tab, skip it.

Formidable Forms Pro runs it for each query it builds, such as for graphs and Dynamic fields, with $exclude set to true. Formidable Views leaves spam entries out of Views on its own and doesn't run this filter.

When a Lite query selects specific entries by ID or key, spam entries stay in the results. For a query built as an array, the filter still runs with $exclude already false. For a query built as an SQL string, it doesn't run.

Usage

add_filter( 'frm_exclude_spam_entries', 'my_function_name', 10, 2 );

Parameters

  • $exclude (bool): Whether to leave spam entries out of the query. Return false to include them.
  • $where (array|string): The query conditions, as an array or an SQL string.

Examples

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

Count all entries of a form, including spam

This example adds the filter around a single entry count, then removes it. Other entry queries on the page keep leaving spam out. Put these lines in your own code where you need the count, such as a shortcode or template function. Replace 5 with the ID of your form.

add_filter( 'frm_exclude_spam_entries', '__return_false' );
$total_entries = FrmEntry::getRecordCount( 5 ); // Change 5 to the ID of your form.
remove_filter( 'frm_exclude_spam_entries', '__return_false' );

To count only the spam entries of a form, use FrmSpamEntriesHelper::count( 5 ) instead.

Limitations

  • Returning false for every query adds spam entries to entry counts, graphs, and exports across the site. Add the filter only around your own query, as in the example.
  • The filter doesn't change Views. To show spam entries in a View, filter the View by Entry status equals Spam.
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