-
Notifications
You must be signed in to change notification settings - Fork 0
Forms restrictions and anti spam measures
Michele Mizejewski edited this page Sep 13, 2021
·
19 revisions
All forms created with WPForms are protected.
- First, generate a reCAPTCHA key in Google. See plugin documentation for all details.
- Then go back to the WordPress dashboard > WPForms > Settings > reCAPTCHA and enter the key
- For each form, go to Settings > General and check Enable anti-spam honeypot and Enable Google Checkbox v@ reCAPTCHA
Need to limit submissions for DPH ILL requests to users with an email address @sfdph
WPForms provides options to limit or block email address form fields.
- 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 );
- Add the edited code via the plugin Code Snippets
Still have questions? Contact the Library User Experience Team.