Docs & Support

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

frm_spam_entry_sources

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_entry_sources filter to add your own spam check to the checks that can save a submission as a spam entry. Each check in the list gets its own row in the spam check settings.

In that row, a site admin chooses whether submissions your check flags are saved as spam entries or rejected. Your own code still decides when a submission is spam.

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.

How it works

The filter adds your check under Formidable → Global Settings → Captcha/Spam → Spam checks, in the Customize how spam submissions are handled section. Its dropdown offers Save as a spam entry and Reject with an error message. Learn more about spam checks.

Your code runs the check, usually in the frm_validate_entry filter. When a submission fails it, call FrmSpamEntriesHelper::maybe_flag_submission():

  • It returns true when your check is set to save. The submission is saved as a spam entry. The visitor sees the normal success message.
  • It returns false when your check is set to reject, or when spam entries can't be saved on the site. Add an error so the submission is rejected.

Only new submissions can be saved as spam entries. When an entry is being edited, reject it instead.

In the Spam tab of the entries list, the entry's spam reason shows your label and the reason you passed, such as "Disposable email address: mailinator.com".

Usage

add_filter( 'frm_spam_entry_sources', 'my_function_name' );

Parameters

  • $sources (array): The spam checks, keyed by a unique source key such as honeypot or akismet. Each check is an array with a label and a default.
  • $sources[ $key ]['label'] (string): The check's name in the settings and in the spam reason.
  • $sources[ $key ]['default'] (string): save to save flagged submissions as spam entries, or block to reject them. It applies until a site admin saves a different choice.

FrmSpamEntriesHelper::maybe_flag_submission() parameters

  • $form_id (int): The ID of the submitted form.
  • $source (string): The source key of your check.
  • $reason (string, optional): Details shown after the label in the spam reason.

Examples

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

Save submissions from disposable email addresses as spam

This example adds a "Disposable email address" check. It flags new submissions whose email address uses one of the listed domains. Replace 25 with the ID of your Email field. Then list the domains you want to catch.

add_filter( 'frm_spam_entry_sources', 'my_frm_add_spam_source' );
function my_frm_add_spam_source( $sources ) {
	$sources['disposable_email'] = array(
		'label'   => 'Disposable email address',
		'default' => 'save',
	);
	return $sources;
}

add_filter( 'frm_validate_entry', 'my_frm_check_disposable_email', 20, 2 );
function my_frm_check_disposable_email( $errors, $values ) {
	if ( $errors ) {
		return $errors; // The submission already has errors.
	}

	$field_id = 25; // Change 25 to the ID of your Email field.
	$email    = isset( $values['item_meta'][ $field_id ] ) ? strtolower( trim( (string) $values['item_meta'][ $field_id ] ) ) : '';
	$domain   = false !== strpos( $email, '@' ) ? substr( strrchr( $email, '@' ), 1 ) : '';
	$blocked  = array( 'mailinator.com', 'yopmail.com' );

	if ( ! in_array( $domain, $blocked, true ) ) {
		return $errors;
	}

	$is_new = empty( $values['id'] ) && 'update' !== ( $values['frm_action'] ?? '' );

	if ( ! $is_new || ! FrmSpamEntriesHelper::maybe_flag_submission( $values['form_id'], 'disposable_email', $domain ) ) {
		$errors['spam'] = 'Please use a different email address.';
	}

	return $errors;
}

Limitations

  • The filter adds the setting and the spam reason label. The check itself runs only where your code calls FrmSpamEntriesHelper::maybe_flag_submission().
  • Flagging a submission while an entry is being edited has no effect. The example rejects edits that fail the check instead.
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