How are you searching for this user? Either way, this it the function you want to use, as it can look via ID, user_nicename
, email and login.
e.g.:
$userEmail = $_GET['useremail'];
$field = 'email';
$user = get_user_by( $field, $userEmail );
if(!$user) {
$newUserArgs = array(
'user_login' => $_GET['userlogin'],
'user_pass' => $_GET['hashedpass'],
'user_email' => $_GET['useremail']
);
$user = wp_insert_user( $newUserArgs );
}
$user
now has user in it. Either it found an existing one, or created one. As you can see I’ve assumed you are passing in userlogin, hashedpass and useremail from a form or such.
Hope this helps.