Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created February 25, 2017 20:28

Revisions

  1. joshfeck created this gist Feb 25, 2017.
    24 changes: 24 additions & 0 deletions ee_add_unique_email_validation.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    <?php
    //* Please do NOT include the opening php tag, except of course if you're starting with a blank file

    function ee_add_unique_email_validation(){
    wp_add_inline_script(
    'single_page_checkout',
    'jQuery( document ).ready(function($) {
    $(".ee-reg-qstn-email").addClass("unique");
    $.validator.addMethod("unique", function(value, element) {
    var parentForm = $(element).closest("form");
    var timeRepeated = 0;
    if (value != "") {
    $(parentForm.find(":text")).each(function () {
    if ($(this).val() === value) {
    timeRepeated++;
    }
    });
    }
    return timeRepeated === 1 || timeRepeated === 0;
    }, "* Duplicate! Please use a unique email address");
    } );'
    );
    }
    add_action( 'wp_enqueue_scripts', 'ee_add_unique_email_validation', 60 );