Support » Plugins » Contact form 7 – double email field

  • I have seen this issue raised elsewhere, but unresolved. As I am getting rather desperate to have this question answered I am asking here.

    I am using this contact form for a school website. As you may have guessed, we have many students who are not paying attention when entering their email addresses and enter them incorrectly. What I need is to have a double email field that users can enter their email address twice and have each checked against the other for correctness.

    Can someone tell me how this is done please?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Sorry to be persistent, but I really need an answer on this one or I may have to find another avenue to achieve what I need.

    Can ANYONE tell me how to have 2 email fields check each other for accuracy with Contact 7?

    Thanks.

    esmi

    (@esmi)

    Forum Moderator

    Call me stupid, but I have read through this information already and didn’t see anything that is what I am looking for. I can easily add a second email field, but I can enter 2 different emails, which is not what I need. I need to have a user enter their same email address twice and it has to be the same in the 2 fields. If one doesn’t match the other, I need the form to reject it and not send. Is this easily done? and how?

    Contact Form 7 doesn’t have such a feature and there is no plan to implement it in the future releases. I think it’s useless because everybody knows “Copy & Paste”.

    esmi, I do appreciate you replying to me, but clearly my reading the documentation (which I had already done) wouldn’t have helped.

    takayukister
    Thank you for that answer. I now know that I can stop bugging people for an answer.

    In my particular case, my students aren’t crafty enough to do the copy thing, though I totally know what you’re saying.
    Has anyone out there managed to implement a duplicate email field? Or know how I might hack the plugin to include one? It’s really annoying to respond to a student’s comment when they’ve provided the wrong email address. With 30 comments submitted so far, I’ve had 7 with wrong email addresses.

    Did you end up figuring out how to do this? or did you change to another contact form?

    I want to use this one, but I think I might need to change since there isn’t a feature.

    I have a web page that people often use on mobile phones, hence email addresses are often put in incorrectly.

    I have had about 10 contacts and 5 of them have incorrectly entered the email address.

    I can’t reply to these people so now I ask for a mobile number, and made another field for “check your email address”

    It would be nice to be able to say only accept email if <email field1> = <email field 2>

    I have read the fAQ and all that, can’t find anything that helps.

    Alright, after 5 hours I’ve finally figured it out. So what you’ll need to do is open the text.php file in the module folder in the plugin directory: contact-form-7/modules/text.php

    On line 95 is where the validation function is for the email fields. All you need to do is add on another “elseif” statement using the same structure from line 114 to 117 which looks like this:

    elseif ( '' != $_POST[$name] && ! is_email( $_POST[$name] ) ) {
    			$result['valid'] = false;
    			$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_email' );
    		}

    Now we just modify this statement to say if ’email1′ is not equal to ’email2′ then is invalid. So the new validation statement will look like this:

    elseif ( $_POST['email1'] != $_POST['email2'] ) {
    			$result['valid'] = false;
    			$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_email' );
    		}

    Where ’email1′ and ’email2′ are the email field names you set up in the Contact Form 7 admin area. So the full validation statement will look like this:

    if ( 'email' == $type || 'email*' == $type ) {
    		if ( 'email*' == $type && '' == $_POST[$name] ) {
    			$result['valid'] = false;
    			$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_required' );
    		} elseif ( '' != $_POST[$name] && ! is_email( $_POST[$name] ) ) {
    			$result['valid'] = false;
    			$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_email' );
    		}elseif ( $_POST['email1'] != $_POST['email2'] ) {
    			$result['valid'] = false;
    			$result['reason'][$name] = $wpcf7_contact_form->message( 'invalid_email' );
    		}
    	}
    
    	return $result;

    Now you’ll be able to validate 2 email fields while still being able to have other forms with single email validation using the same plugin. Enjoy.

    I have an alternate work around which doesn’t require you to edit any core files or plugin files.

    This can also be used for email validation. Solves the missing password input type for Contact Form 7 as well.

    http://www.pinwire.com/sci-tech/wordpress-password-field-validator

    C’รจ un Plugin: Fast Secure Contact Form che ti chiede 2 volte l’email per fare la convalida. ciao axter.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Contact form 7 – double email field’ is closed to new replies.