Languages: English • Italiano • 日本語 (Add your language)
This function will check whether or not a given email address ($email) has already been registered to a username, and returns that users ID (or false if none exists). See also username_exists.
This function is normally used when a user is registering, to ensure that the E-mail address the user is attempting to register with has not already been registered.
<?php
if ( email_exists( $email ) ) {
// Stuff to do when email address exists
}
?>
If the E-mail exists, echo the ID number to which the E-mail is registered. Otherwise, tell the viewer that it does not exist.
<?php
$email = 'myemail@example.com';
$exists = email_exists( $email );
if ( $exists ) {
echo 'That E-mail is registered to user number ' . esc_html( $exists );
} else {
echo 'That E-mail doesn\'t belong to any registered users on this site';
}
?>
Since: 2.1.0
email_exists() is located in wp-includes/user.php