Is there a way to manually override someone's CiviCRM ID?

A long time member of ours got his original ID number from our previous database. When we switched to Civi, it changed his ID. He would like his old ID number back.


  • perhaps explain if the ID the contact 'wants' already exists, etc. – petednz - fuzion Feb 7 '17 at 18:47

If there is a contact (y) with that ID already then one option via the UI would be

  • create a new contact (z). Then merge z and y so that z inherits all the information for contact y
  • retrieve y from trash, and go through the same steps of merging y with x (your original contact) such that y inherits all the info from x.

Outcome should be that your original contact will now have the ID of y.

  • Thanks for your help! Unfortunately, no one in our database has the specific ID. – Peter Dodge Feb 7 '17 at 21:23
  • because it has been used and contact deleted, or your sequence of numbers hasn't gotten that high? if the former you may be able to do a sql insert – petednz - fuzion Feb 8 '17 at 5:20

Assuming the id has already come and gone.

Create a new person of the same type. Give them the same name so you can find and merge later. Only give them a name. Don't give them an address or email or anything else. Otherwise you'll be creating records in other tables.

Using sql or phpadmin or some other sql tool update the contact id to the one you want.

update civicrm_contact set id = wantedid where id = id_of_newly_created

Now merge the old person into the newly created re-id'd person.

As always with stuff like this test in a development environment first.

Caveats: You might find that the swapping id's errors with foreign key constraints. If so, look at the constraint and delete the record from that table that matches the new contact_id. You may have to do this a few times if there is more than one. I found that custom fields sets that were set to view inline each had a record.

  • It's funny I was just testing this very thing. We have a couple of people who have recurring donations that got setup on the individual and they want the donations to be on the household. Since I don't think you can change the IPN stuff, one solution is to change the id's of the people. – Paul-Tahoe Feb 11 '17 at 2:57
  • I did try to just insert a record with the id and the bare minimum and then do the merge to that. You don't end up with a hash for that person and merging, editing, etc. doesn't seem to create one. – Paul-Tahoe Feb 11 '17 at 3:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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