• Resolved word1press

    (@word1press)


    Hi, how to prevent users with an email address that includes a plus sign (i.e. [email protected]) from submitting the form? I tried to use *+* in the deny list, but it rejects all email addresses.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @word1press,

    Hope you are doing well.

    I can reproduce the behavior on my site too. It’s not just *+* it’s also other special characters such as *%* , *&*, *#* , *(* ETC.

    Notice when you save the Denylist rule, the list item *+* becomes ** , here is a screenshot https://i.imgur.com/6d6NSXc.jpg and that’s the reason why the WPForm Email Field is rejecting all the email address no matter if it contains a + sign or not.

    So, I believe it’s a limitation of using special characters with Wildcards in WPForms as it may cause issues with the WPForm form core code. By the way, I also tested *-* and it worked perfectly. So there are some special characters that are not allowed and one of them being the +.

    I hope this helps

    CC: @jadealombro this guide should be updated with the information I provided above.

    Take Care ??

    • This reply was modified 3 years, 5 months ago by IndiCartel.
    Plugin Support Kenneth Macharia

    (@kmacharia)

    Hey @word1press

    I can recommend using the code snippet below to check for the + sign in the email address:

    
    // Block submissions from email addresses that contain + symbol
    function wpf_blacklist_emails( $field_id, $field_submit, $form_data ) {
        //
        if( strpos($field_submit, "+") !== FALSE ) { 
            wpforms()->process->errors[ $form_data['id'] ][ $field_id ] = esc_html__( 'We apologize for any inconvenience, we are unable to accept submissions using your email address.', 'wpforms' );
            return;
        }
    }
    add_action('wpforms_process_validate_email', 'wpf_blacklist_emails', 10, 3 );

    In case it helps, here’s our tutorial with the most common ways to add custom code like this.

    For the most beginner-friendly option in that tutorial, I’d recommend using the Code Snippets plugin.

    @rizwan681 Thank you for your feedback, I will pass this on to the internal team. The following list of symbols have special meaning and might result in unexpected behavior:
    [ \ ^ $ . | ? * + ( )

    Thanks! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Deny an email address with plus sign’ is closed to new replies.