When making a registration and saving information in the database I want to check if the user's email has already been registrated.

function user_id_exists($user){
    global $wpdb;

    $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->users WHERE ID = %d", $user));

    if($count == 1){ return true; }else{ return false; }

It should be something like this

1 Answer 1


There's the email_exists() function that could help you with checking if an email already exists among users.

It's e.g. used by register_new_user().

More here:



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.