How to Block Spam Words in WPForms Without Premium Version

How to Block Spam Words in WPForms Without Premium Version

Spam submissions cluttering your WPForms? Fret not! With a simple tweak, you can effectively block spam words without the need for the premium version.Are you tired of sifting through form submissions cluttered with spammy offers and promotions? In today’s digital landscape, every cent counts, and every interaction matters.

But fear not! There’s a cost-effective solution to combat spam and maintain the integrity of your form submissions without breaking the bank Follow these steps to reclaim control over your form submissions:

Important: Before proceeding with any code modifications, make sure to back up your website to prevent data loss in case of any unexpected issues.

Step 1: Access Your WordPress Dashboard

  • Log in to your WordPress admin dashboard using your credentials.

Step 2: Navigate to the WPForms Plugin

  • From the WordPress dashboard, navigate to the “WPForms” menu item on the left sidebar.
  • Click on “All Forms” to view a list of your existing forms.

Step 3: Find the Form ID

  • Identify the form you want to apply the word blocking to.
  • Wpform Dashboard and copy ids from here .

Step 4: Update the Code with the Form ID

  • Take note of the form ID for the form you want to apply the word blocking to.
  • Open the “functions.php” file of your theme in the theme editor and paste the code at the end.

Step 5: Integrate Form ID into Code

  • In the $form_ids_to_validate array, add the form ID(s) you noted down in Step 3.
  • Ensure that each form ID is separated by a comma and enclosed in single quotes
function custom_wpforms_validate( $field_id, $field_submit, $form_data ) {
    // List of form IDs to apply the validation to
    $form_ids_to_validate = array( 5846, 5526, 5447 );

    // Check if the form ID is in the list of form IDs to validate
    if ( in_array( $form_data['id'], $form_ids_to_validate ) ) {
        // List of blocked words
        $blocked_words = array(
            'job', 'offer', 'seo', 'service', 'promotion', 'free', 'money', 'cash',
            'earn', 'income', 'investment', 'loan', 'credit', 'mortgage', 'insurance',
            'discount', 'deal', 'bargain', 'cheap', 'save', 'winner', 'winning',
            'prize', 'bonus', 'gift', 'click', 'buy', 'purchase', 'order', 'subscribe',
            'signup', 'sign up', 'sale', 'special', 'urgent', 'limited', 'hurry',
            'act now', 'exclusive', 'trial', 'risk-free', 'guarantee', 'offer expires'

        // Iterate through each blocked word
        foreach ( $blocked_words as $word ) {
            // Check if the submitted value contains any blocked word
            if ( stripos( $field_submit, $word ) !== false ) {
                // Add error to the field
                wpforms()->process->errors[$form_data['id']][$field_id] = 'This field contains forbidden words.';

// Hook into the field validation process
add_action( 'wpforms_process_validate_field', 'custom_wpforms_validate', 10, 3 );


Step 6: Test Your Forms

  • Now that the code is added, it’s time to test your forms.
  • Submit a form with values containing blocked words to ensure the validation works as expected.

Step 7: Monitor Form Submissions

  • Regularly monitor your form submissions to ensure spam words are effectively blocked.
  • Adjust the list of blocked words as needed to keep up with changing spam trends.


We hope this code and guide will work for you and help you keep your WPForms submissions clean from spam words. By following these steps, you can save time and maintain the quality of your data without incurring additional costs. However, if you still face any issues or need further assistance, we are here to help you. Feel free to reach out with any questions or concerns, and we’ll be happy to assist you!