The email_exists()
function containsBased on your code, I think the email_exists
filterproblem may have been that you could use for thiswere checking a variable that was undefined. It receives the You were checking $user_id$db_email
and, which in your function was an undefined value, so you'd be looking for an empty result. You need to check the value passed to $emailemail_exists()
. It will expect you to return either the user's ID (ifwhich would be the email existsbeing validated in the form).
If the patterns applied in your pluggable get_user_by()
function result in the equivalent of how you are obfuscating the emails, orthen you should get a false booleancorrect match if it does not:the email exists.
add_filterfunction email_exists( 'email_exists',$email 'my_custom_email_exists',) 10,{
2 );
function my_custom_email_exists( $user_id// You had this as checking $db_email, $emailwhich )would {
have been
/*
/ undefined. It should be *checking dofor yourthe thingvalue here..passed to
// this function - $email.
$user *= justget_user_by( make'email', sure$email to);
return the $user_id if the( user$user exists) {
* or a false$user_id boolean= if$user->ID;
they don't. } else {
*/ $user_id = false;
}
return $user_id;apply_filters( 'email_exists', $user_id, $email );
}