WordPress validate Email address
WordPress have two functions using you can validate email address. So you don’t have to add extra functionality for the validation using regular expressions.
Validate Email
You can validate email using following code
<?php $email_address='admin@mywebsite.com'; if (empty($email_address) || !is_email($email_address)) { echo 'Not A Valid Email address'; } else { // successful } ?>
Email Exists Check
To check if the email address is present in the wordpress website database you have to use email_exists() function it returns ID of the user to whom the E-mail is registered. and False if email not exists.
<?php $email = 'myemail@example.com'; if ( email_exists($email) ) { echo "That E-mail is registered to user number " . email_exists($email); } else { echo "That E-mail doesn't belong to any registered users on this site"; } ?>