Answers.Body: <p>The issue outlined in the question and comments doesn't exist in the latest version of CiviCRM.  Penny mentions that the issues results because "When a Wordpress User is deleted, the WP User ID is not deleted from that contact's CiviCRM contact record".  </p>
  
  <p>I tested that this is no longer the case by creating a WordPress user, running <code>SELECT * from civicrm_uf_match</code> to find the corresponding entry in that table, then deleting the WordPress user.  When I re-ran the SQL statement, I saw that the <code>civicrm_uf_match</code> entry was gone.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-06T07:02:32.050Z
Answers.LastActivityDate: 2017-01-06T07:02:32.050Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>Certainly with Drupal, the user account is linked to the civi record via a table called uf_match. That table contains primary email address, drupal user id and civicrm contact id (and other fields not relevant to this question). It is that table that is checked to see if a record already exists for such a user. So it sounds like this would be an extra feature requirement for civi, and i have no idea how complex, so can't be more helpful at this point.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-02-10T18:57:52.293Z
Answers.LastActivityDate: 2016-02-10T22:29:33.177Z
Answers.LastEditDate: 2016-02-10T22:29:33.177Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>We are running WordPress 4.4.2, CiviCRM 4.6.12, and the CiviCRM WordPress Member Sync and CiviCRM WordPress Profile Sync plugins.</p>
  
  <p>Whenever someone logs in with a WordPress user ID / email that is not their primary CiviCRM contact email, a new CiviCRM contact is created. The WP email may be listed as their "home" / "work" / "billing" / etc. email in CiviCRM but a new contact is still created. </p>
  
  <p>In the newly created CiviCRM contact, the email address is set as "home" and "primary". The next time they login, a new contact is created, again with the email set as "home". We end up with a lot of duplicate contacts!</p>
  
  <p>Is this a plugin issue, or a CiviCRM issue?</p>
  
  <p>It seems similar to the question here: <a href="https://civicrm.stackexchange.com/questions/197/wordpress-duplicates-my-contacts">Wordpress duplicates my contacts</a></p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-10T13:30:17.253Z
Comments.Text: How is the mismatch happening? Are you changing the email address of the contacts in question to something other than "primary" in CiviCRM?
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-16T03:29:53.750Z
Comments.Text: Sorry, I don't understand what you mean. Yes, the email addresses used in WordPress may not be their "primary" CiviCRM address. So I guess the answer is to make sure that the primary email addresses are consistent? However that doesn't explain why they continue to get more duplicate entries.
Comments.UserDisplayName: Esther
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-16T09:51:04.440Z
Comments.Text: If the email used in WordPress is different to the primary email in CiviCRM, then uf_match considers them to be different users. Hence the "duplication", whether the sync happens via the CiviCRM plugin or one of my plugins.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-17T06:01:48.540Z
Comments.Text: But then why does it keep happening? Surely once there are two entries, the new one with the email as "primary" and the original/older one with it as "work"/"home"/etc. and not primary, there shouldn't be any more created?
Comments.UserDisplayName: Esther
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-02-17T10:39:42.503Z
Comments.Text: Please post the steps to reproduce your duplication scenario. Without those steps I'm as much in the dark as you are!
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-18T09:58:08.997Z
Comments.Text: OK with further investigation, I think I've discovered the problem. When a Wordpress User is deleted, the WP User ID is not deleted from that contact's CiviCRM contact record. Then, when a new WP User is added with the same email address as before, it is not linked to their CiviCRM contact record because there is already a WP User ID linked to it. A new CiviCRM Contact record is created each time that user logs in. I solved the issue by going to the wp_user table in the database and changing the WP user ID back to the original ID (the one linked to in the CiviCRM contact record).
Comments.UserDisplayName: Esther
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-18T10:03:25.730Z
Comments.Text: A solution would be not to delete WP Users but I do this when they want to change their username.
Comments.UserDisplayName: Esther
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-03-18T13:27:51.897Z
Comments.Text: From which admin page are you deleting the Users? This sounds like a CiviCRM integration bug if it doesn't also delete the `uf_match` entry
Comments.UserDisplayName: Christian Wach
Tags: <wordpress><duplicate-contacts>
Title: Multiple contact entries created for WordPress users if they login with non-primary email addresses
ThreadText: # Multiple contact entries created for WordPress users if they login with non-primary email addresses
  
  (Asked by: username_0 on 2016-02-10)
  
  We are running WordPress 4.4.2, CiviCRM 4.6.12, and the CiviCRM WordPress Member Sync and CiviCRM WordPress Profile Sync plugins.
  
  Whenever someone logs in with a WordPress user ID / email that is not their primary CiviCRM contact email, a new CiviCRM contact is created. The WP email may be listed as their "home" / "work" / "billing" / etc. email in CiviCRM but a new contact is still created.
  
  In the newly created CiviCRM contact, the email address is set as "home" and "primary". The next time they login, a new contact is created, again with the email set as "home". We end up with a lot of duplicate contacts!
  
  Is this a plugin issue, or a CiviCRM issue?
  
  It seems similar to the question here: [Wordpress duplicates my contacts](https://civicrm.stackexchange.com/questions/197/wordpress-duplicates-my-contacts)
  
  **Tags:** wordpress, duplicate-contacts
  
  > **Comments:**
  > **username_1**: How is the mismatch happening? Are you changing the email address of the contacts in question to something other than "primary" in CiviCRM?  
  > **username_0**: Sorry, I don't understand what you mean. Yes, the email addresses used in WordPress may not be their "primary" CiviCRM address. So I guess the answer is to make sure that the primary email addresses are consistent? However that doesn't explain why they continue to get more duplicate entries.  
  > **username_1**: If the email used in WordPress is different to the primary email in CiviCRM, then uf_match considers them to be different users. Hence the "duplication", whether the sync happens via the CiviCRM plugin or one of my plugins.  
  > **username_0**: But then why does it keep happening? Surely once there are two entries, the new one with the email as "primary" and the original/older one with it as "work"/"home"/etc. and not primary, there shouldn't be any more created?  
  > **username_1**: Please post the steps to reproduce your duplication scenario. Without those steps I'm as much in the dark as you are!  
  > **username_0**: OK with further investigation, I think I've discovered the problem. When a Wordpress User is deleted, the WP User ID is not deleted from that contact's CiviCRM contact record. Then, when a new WP User is added with the same email address as before, it is not linked to their CiviCRM contact record because there is already a WP User ID linked to it. A new CiviCRM Contact record is created each time that user logs in. I solved the issue by going to the wp_user table in the database and changing the WP user ID back to the original ID (the one linked to in the CiviCRM contact record).  
  > **username_0**: A solution would be not to delete WP Users but I do this when they want to change their username.  
  > **username_1**: From which admin page are you deleting the Users? This sounds like a CiviCRM integration bug if it doesn't also delete the `uf_match` entry  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2017-01-06. Score: 3
  
  The issue outlined in the question and comments doesn't exist in the latest version of CiviCRM. Penny mentions that the issues results because "When a Wordpress User is deleted, the WP User ID is not deleted from that contact's CiviCRM contact record".
  
  I tested that this is no longer the case by creating a WordPress user, running `SELECT * from civicrm_uf_match` to find the corresponding entry in that table, then deleting the WordPress user. When I re-ran the SQL statement, I saw that the `civicrm_uf_match` entry was gone.
  
  
  ---
  
  ### Answer by username_3 on 2016-02-10. Score: 0
  
  Certainly with Drupal, the user account is linked to the civi record via a table called uf\_match. That table contains primary email address, drupal user id and civicrm contact id (and other fields not relevant to this question). It is that table that is checked to see if a record already exists for such a user. So it sounds like this would be an extra feature requirement for civi, and i have no idea how complex, so can't be more helpful at this point.
  
  
  ---
  
  