Prevent form submission based on entered field values

Prevent form from being submitted by comparing entered field values. Useful when you want to prevent a specific user or bot from submitting the form. Returns a fake success message to the user.

The below action hook only works with Super Forms v6.3.708+

add_action('super_before_processing_data', function($atts){
  $data = $atts['atts']['data'];
  // Return fake message when one of the following fields matches the value
  $checks = array(
    'email' => array(
    'phonenumber' => array(
    'my_field_name' => array(
  foreach($checks as $fieldName => $compare){
    // Skip if field with this name does not exists in the form
    if(!isset($data[$fieldName])) continue; 
    // Compare the entered value in the form with the one we defined
    if(in_array(trim($data[$fieldName]['value']), $compare)) {
        'msg' => '<h1>Thank you!</h1>We will reply within 24 hours (fake message to pretent succesful submission, but nothing really happened)'

Last updated