WordPress.org

Ready to get started?Download WordPress

Forums

Contact Form 7
[resolved] Remove Email Validation? (4 posts)

  1. richsadams
    Member
    Posted 1 year ago #

    We use Contact Form 7 plugin on our church website. Currently the form requires an email address and validates it.

    Some people may want to contact us that do not have an email address (they may access our website from the library, etc.). The ideal situation would be to have the email validated if something is entered in that field, but not require the field be filled in. I don't think that's possible, but it would be great if that were possible.

    So I am considering removing the "required"/validation element. I want to leave the field for folks that do want to share their email address, but I don't want it to be "required".

    Should I have any concerns about doing this such as security, etc.?

    Also I'm sure I can find the validation PHP code to change it, but if anyone knows exactly where it is, that would be helpful.

    TIA!

    http://wordpress.org/extend/plugins/contact-form-7/

  2. Takayuki Miyoshi
    Member
    Plugin Author

    Posted 1 year ago #

    http://contactform7.com/text-fields/

    email -> optional
    email* -> required

    Simply change the type of the tag. Not necessary to edit any PHP code.

  3. richsadams
    Member
    Posted 1 year ago #

    Ah, thanks very much for that. Simple!

    Uh oh. Doing as suggested leads to another issue indicating that what I'd like to do may not be possible.

    If I change the email field to "not required" and the form is submitted without an email address it does not generate an email notice to our own designated email address.

    So it looks like CF7 must have a "required" email address to work as intended.

    Thank you again for the speedy advice. If you can think of another way (besides using a different plugin) that we can accomplish our goal it would be most welcome...CF7 seems like a very good plugin otherwise.

    Best wishes!

  4. richsadams
    Member
    Posted 1 year ago #

    Success! I put my thinking cap on and figured out how to accomplish this.

    In order to do what I wanted I ended up deleting the default email code in the CF7 Form editor:

    Your Email (required)
    [email* your-email]

    And replaced it by using the CF7 "Generate Tag" drop-down menu > Email Field and leaving the "Required field?" unchecked. I named it "email NR". This is short-code for that:

    Your Email
    [email email-NR]

    I added it to the form and tah-dah! I tested it and the contact form works AND generates a notice to our email with the person's name <"[your-email]"@"our server name". So when no email address is entered it just sends the sender's name/message via our server address instead. The rest looks normal.

    The icing on the cake is that IF an email address is entered in the field it is still validated. Sweet.

    Thanks very much for your feedback Takayuki and hope this helps someone else.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic