Hi.

I suggest return uid if user exists, but uid is unknown.

Look at this code (file user_service.inc):


function user_service_save($account) {
  // if uid is present then update, otherwise insert
  $update = user_load($account['uid']);


+  // try to get user by mail if uid is unknown
+  if (!$update) {
+    $sql = 'select `uid` from {users} where `mail` = "%s"';
+    $u = db_fetch_array( db_query($sql, $account['mail']) );
+    if ($u['uid'] > 0) return $u['uid'];
+  }


  $account = isset($update->uid) ? user_save($update,$account) : user_save('', $account);
  if (!$account) {
    return services_error(t('Error on saving the user.'));
  }

  // Everything went right.
  // Return the user ID
  return $account->uid;
}

Comments

marcingy’s picture

Status: Patch (to be ported) » Needs work

Please supply a patch, code according to drupal standards and tidy up the code. Once this is done with feature request may be considered.

gdd’s picture

Status: Needs work » Closed (won't fix)