I am trying to validate duplicate email using jquery Validate plugin in wordpress.But for some reason the function returns 0 always.

jQuery code:

 email: {
           required: true,
           email: true,
           "remote":
                   {
                      url: CartAjax.ajaxurl,
                      type: "post",
                      data:
                          {
                            email: function()
                            {
                             return $('#frmorder :input[name="email"]').val();
                            },
                             action: 'duplicate_email_check'
                          }
                        }
         },

In my theme functions.php

add_action('admin_post_duplicate_email_check', 'duplicate_email_check');
add_action('admin_post_nopriv_duplicate_email_check', 'duplicate_email_check');

function duplicate_email_check()
{
    echo "true";
die();
}

If true it should return 1 instead 0 but it’s returning 0 always.

Any help is highly appreciated.

Read more here: Duplicate email validation using jquery validate in wordpress


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: