Skip to content

Forms restrictions and anti spam measures

Michele Mizejewski edited this page May 11, 2022 · 19 revisions

Anti-spam measures for Elementor forms

  • all newsletter subscribe forms are Elementor
  • they have Honeypot protection added to each form
  • CAPTCHA is possible, but would require rethinking our minimal design, since it adds a big section.

Anti-spam measures for Zendesk forms

  • all have CAPTCHA?

Anti-spam measures for WPForms

  • WPForms own Enable anti-spam protection option should be toggled on by default
  • Note that anti-spam honeypot was included for any forms created prior to the 1.6.2 release. However, newer forms will only have the anti-spam protection option.
  • As of May 2022, enabled WPForms spam protection on all forms and turned off the obsolete honeypot setting on older forms.

Currently applied to all forms, but need to review options due to accessibility issues

  1. First, generate a reCAPTCHA key in Google. See plugin documentation for all details.
  2. Then go back to the WordPress dashboard > WPForms > Settings > reCAPTCHA and enter the key
  3. Once reCAPTCHA is activated (previous step) it must be toggled on for each form. Go to Settings > General and check Enable anti-spam and Enable Google Checkbox v2 reCAPTCHA

captcha settings

Forms restrict email domain

Problem

Need to limit submissions for DPH ILL requests to users with an email address @sfdph

Solution

WPForms provides options to limit or block email address form fields.

limit domain

Solution (older and no longer needed)

  1. Get a snippet from WPForms support and customize to include the desired domain and the specific form ID
/*
 * Whitelist email domains from your WPForms.
 *
 * @link https://wpforms.com/developers/how-to-restrict-email-domains/
 *
*/
function wpf_whitelist_domains( $field_id, $field_submit, $form_data ) {
    $domain          = substr( strrchr( $field_submit, "@" ), 1 );
    $whitelist       = array( 'sfdph.org' );
    if( ! in_array( $domain, $whitelist ) && $form_data[ 'id' ] == 15647 ) {
        wpforms()->process->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'Email domain must be @sfdph.org', 'wpforms' );
        return;
    }
}
add_action('wpforms_process_validate_email', 'wpf_whitelist_domains', 10, 3 );
  1. Add the edited code via the plugin Code Snippets

snippets plugin

Clone this wiki locally