Well, you comparing the results of the email_exists
function with $current_user->ID
. If email exists, email_exists()
return the ID of the user using that email or false if the email doesn’t exists. Imaging you are checking a email not being using, email_exists()
return false and this if
will validate:
elseif(email_exists(esc_attr( $_POST['email'] ) ) != $current_user->ID )
Do you see the error?
You should modify the above line with something like:
elseif( email_exists(esc_attr( $_POST['email'] ) ) && email_exists(esc_attr( $_POST['email'] )) != $current_user->ID )