Answers.Body: <p>If the <code>UserModel</code> contains a user ID, then the existing user will be <em>updated</em>.</p>
  
  <p>If the <code>UserModel</code> does not contain a user ID, then a new user will be <em>created</em>.</p>
  
  <p>Either way, the <code>UserModel</code> will contain an ID after being saved. Since models in PHP are passed by reference, the ID will get set automatically for new users.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T18:30:34.543Z
Answers.Text: Thanks for the reply, but that's not the question. I want a newly created user to have exactly the same ID as it was in the previous database.
Answers.UserDisplayName: Tibor Szasz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T19:13:36.970Z
Answers.Text: Ah, that was not clear in the original question.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T19:14:32.730Z
Answers.Text: And if I guess right it's not doable?
Answers.UserDisplayName: Tibor Szasz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T19:15:19.307Z
Answers.Text: It's probably doable, but complicated. I'll let someone else take a shot at answering that.
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T19:18:46.017Z
Answers.Text: I think I'll do a surgical fix: add back the new user ID-s to the old tables and export them with the fresh ID-s :) Ugly, but only needs to be done once.
Answers.UserDisplayName: Tibor Szasz
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T17:43:10.760Z
Answers.LastActivityDate: 2016-09-29T17:43:10.760Z
Answers.UserDisplayName: Lindsey D
Body: <p>Is it possible to use the saveUser method to import users with an existing ID?</p>
  
  <pre><code>craft()-&gt;users-&gt;saveUser($userModel)
  </code></pre>
  
  <p>I need to import 2000+ users and when doing so, I need to make sure that their old ID doesn't change after inserted, because I need to import other tables too and match them based on that.</p>
  
  <p>The excellent import plugin tries to update the users instead of creating new ones when I tell it to import the ID as well. I'm not sure if that's intended behavior or a bug.</p>
  
Tags: <import><plugin-import>
Title: Import users with specific ID
ThreadText: # Import users with specific ID
  
  (Asked by: username_0 on 2016-09-29)
  
  Is it possible to use the saveUser method to import users with an existing ID?
  
  ```
  craft()->users->saveUser($userModel)
  
  ```
  
  I need to import 2000+ users and when doing so, I need to make sure that their old ID doesn't change after inserted, because I need to import other tables too and match them based on that.
  
  The excellent import plugin tries to update the users instead of creating new ones when I tell it to import the ID as well. I'm not sure if that's intended behavior or a bug.
  
  **Tags:** import, plugin-import
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-09-29. Score: 1
  
  If the `UserModel` contains a user ID, then the existing user will be *updated*.
  
  If the `UserModel` does not contain a user ID, then a new user will be *created*.
  
  Either way, the `UserModel` will contain an ID after being saved. Since models in PHP are passed by reference, the ID will get set automatically for new users.
  
  > **Comments:**
  > **username_0**: Thanks for the reply, but that's not the question. I want a newly created user to have exactly the same ID as it was in the previous database.  
  > **username_1**: Ah, that was not clear in the original question.  
  > **username_0**: And if I guess right it's not doable?  
  > **username_1**: It's probably doable, but complicated. I'll let someone else take a shot at answering that.  
  > **username_0**: I think I'll do a surgical fix: add back the new user ID-s to the old tables and export them with the fresh ID-s :) Ugly, but only needs to be done once.  
  
  ---
  
  