wsf_submit_block_keywords

Description

The wsf_submit_block_keywords filter hook enables you to specify an array of blocked keywords that are checked when a form is submitted. WS Form will check all string based input again the blocked keyword array. If a blocked keyword is found, invalid feedback will be shown on the field.

By default this filter hook applies to all forms. You can restrict this filter hook to a specific form by checking the $form->id parameter.

The keyword matching is case-insensitive, meaning it doesn’t matter whether the word is in uppercase or lowercase.

To avoid false positives, WS Form performs whole word matching only. For example, if “art” is a blocked keyword, it will not trigger on safe words like “partial” or “startled.” This helps ensure that valid submissions aren’t mistakenly flagged.

If you need more control with keyword matching, consider using the wsf_submit_field_validate filter hook.

Usage

add_filter( 'wsf_submit_block_keywords', 'my_hook_function', 10, 3 );

Parameters

  1. $keywords Array
    An array of keywords that are blocked.
  2. $form Form Object
    The form object.
  3. $submit Submit Object
    The submit object. Please note that this is a partial submit object because the submit object is still being constructed at the point this filter runs.

Example

// Callback function for the wsf_submit_block_keywords filter hook
function my_hook_function( $keywords, $form, $submit ) {
    
    // Keywords to block
    $keywords[] = 'ranking';
    $keywords[] = 'seo';

    // Return value
    return $keywords;
}

// Add a callback function for the wsf_submit_block_keywords filter hook
add_filter( 'wsf_submit_block_keywords', 'my_hook_function', 10, 3 );

Source File

This hook can be found in: <plugin root>/includes/core/class-ws-form-submit.php