I am in Drupal 7.51 / CiviCRM 4.7.12

I want to check Users emails against their corresponding Contacts emails (which happen to be different in the DB though they should not).

I have developped a small program to identify those cases (querying civicrm_email and drupal_users tables, linked via civicrm_uf_match).

I thought that the civicrm_uf_match table managed the link between the Drupal User id and the corresponding Civicrm Contact id ; but it actually does not : it contains only 31 lines though I have 446 Users and 667 Contacts with a primary email.

For instance, the civicrm_uf_match table does not contain my own ids pair ; moreover, it contains lots of errors (e.g. old emails which were deleted).

Question : how and where is managed this link between the Drupal User and the CiviCRM Contact (which appears when you consult/modify the Contact) ?

3 Answers 3


The civicrm_uf_match table is the correct place to look. I can't explain why you're seeing what you're seeing!

  • Thank you Jon for your answer : I have to trust you : I made some cleaning in my DB some weeks ago (via standard commands, not directly in the tables), because I had fed it by means of successive imports which were not clean ; and I may have lost some connexions at that time. When I cleaned it, I just kept those Users with same Contact email. BTW, I will follow. Thanks again. Dec 1, 2016 at 8:07
  • See also my comment to Fabian Dec 1, 2016 at 8:24

There is a function that synchronizes users and contacts (/civicrm/admin/synchUser?reset=1). Not sure if this would help in any case I recommend trying it on a testing environment first.

  • Thank you Fabian ; I knew this command, but did not dare using it. But I did now, which re-established the link (my civicrm_uf_table contains 442 lines now. But I have a few duplicates (both contacts and users (with same email)) that I must merge now. Thanks again. Dec 1, 2016 at 8:24

When you create a User the user email, civicrm email and uf_match table are all the same.

If you then edit the civicrm email, the uf_match gets updated as does the User email.

If you edit the user email, the uf_match is updated, as is the civicrm email.

BUT I don't think this has always been the case. I can't track when the new feature came in to 4.6.x but I have a strong memory that in the past these were not always kept in synch but can't recall whether it was editing the user email or the civicrm email that would result in only the uf_match being updated but not the 'other end' of the pipe.

  • Thank you Pete for your answer, but I made some tests a few days ago : when you modify the Contact email, the User email is modified accordingly, but when you modify the User email, the Contact email does not follow (I don't know about the uf_match uf_name). Dec 1, 2016 at 7:57
  • Hmm - and I see you are on 4.7.12. Well your outcome is what I expected but I tested on a site and reported what I observed. Jacques if you can fire me your email via fuzion.co.nz/contact I will send you a screencast
    – petednz - fuzion
    Dec 1, 2016 at 19:40

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.