Sometimes we have a email address and we want to check whether it exists in our wordpress database or not. To handle these type of situations we will use default wordpress function that is :


email_exists( $email ); // where $email is the email which we are checking

Note : $email is required parameter in this case, we must put our email in place of $email variable to make this function work.

We can use this in a better way like below :


<?php

$email = "youremail@gmail.com"; // it is the email which you are checking

   if( email_exists( $email )) {

      echo "your email exists in our database";

   }else{

      echo "Sorry, this email is not registered";

    }
?>


This function will return “user id” of the user to which the given email is registered( if registered) otherwise it returns “FALSE”. In this reference, if you want to check whether a email is valid or not then check here : Check email is valid or not in wordpress