Codex

Function Reference/email exists

Contents

Description

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.

Examples

Default Usage

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) ) { . . . } ?>

Detailed Example

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';
  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";
?>

Parameter

$email
(string) (required) The E-mail address to check
Default: None

Return

  • If the E-mail exists, function returns the ID of the user to whom the E-mail is registered.
  • If the E-mail does not exist, function returns false.