Answers.Body: <p>I'm sharing this as I finally found a solution to the question I posted and hopefully it may help someone else who comes across a similar situation. Our organisation is membership based, so when a user sets up a record they are completing a Wordpress form, from which CiviCRM creates a Contact record. At the same time Wordpress creates a Profile which an administrator can access through Users in the menu options. When you look at a Contact record there is a field Contact ID / User ID and each is allocated a number, one of which is a blue link which takes you to the Profile record for that member. To delete a Contact record is very straightforward, but what I didn't realise is that before deleting the Contact record (CiviCRM), you need to delete the Profile record (Wordpress). The system is programmed to create a Contact record to match each Profile record, so if you only delete the Contact record it recreates the Contact record overnight. It's actually very straightforward but it's not covered in the User manual (at least not in the section that relates to deleting Contacts) and has taken me some time to resolve.</p>
  <p>Please note, it may work differently for Drupal so it's worth checking if you are using a CMS other than Wordpress.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-29T18:00:20.163Z
Answers.Text: hmm. yes it is true that a CMS user is connected to a civi record (uf_match table), but i have never seen a situation where if you delete civi user, and do not delete the CMS user (in our case Drupal), that the Civi contact is recreated. maybe a WP scenario only. The Documentation is a community resource - if you feel able to offer an edit then it could help other WP users.
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-29T18:01:41.173Z
Answers.Text: maybe a WP plugin 'does' something over night that reruns the civi record creation?
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-29T18:01:58.367Z
Answers.Text: have raised over here https://chat.civicrm.org/civicrm/pl/gwcn61pdj7nk7g8cba7dw3zk5c
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-29T18:29:59.453Z
Answers.Text: I've reproduced with just WP and Core CiviCRM.   This is intended behavior (well as designed).   Have  contact linked to a  CMS user.  delete the contact,  This should remove the uf_match entry.  permanently deleted - no contact, no entry in uf_match.  If the CMS user logins in again, CiviCRM creates a contact and adds to the uf_match table.   So if you want the CMS user gone, you need to do that manually.  The reasoning is the CMS user could have created content and we don't want to orphan content by deleting a contact.  At least that is why I never looked at changing the behavior.
Answers.UserDisplayName: Kevin Cristiano
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-01T13:26:05.903Z
Answers.Text: Thanks for all your responses. Yes I'm happy to edit my comment to mention that it may work differently for Drupal. Interestingly it was a post on Google relating to Drupal that drew my attention to the solution.
Answers.UserDisplayName: Mary M
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-01T13:33:09.677Z
Answers.Text: Interestingly it was a post on Google relating to Drupal that drew my attention to the solution. I've been doing a data cleanse on our site over the weekend and it's definitely not a plug in that created the situation. It actually makes sense that it's the intended behaviour and I have no issue with how it works, but what would have been a huge help is if there was mention of it in the CiviCRM user guide - specifically in the section relating to deleting civi records.
Answers.UserDisplayName: Mary M
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-01T19:50:45.847Z
Answers.Text: The documentation is a community effort. so, like wikipedia, if you think something is wrong or could be improved then you are welcome to do so. if that seems too daunting, then if you supply a link here to the page in question then someone else in the community may tackle it.
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-10-29T11:38:55.820Z
Answers.LastActivityDate: 2021-11-01T13:38:06.810Z
Answers.LastEditDate: 2021-11-01T13:38:06.810Z
Answers.UserDisplayName: Mary M
Answers.Body: <p>Are those real contacts? Can you check the created date against the contact? It shows up at the bottom when you view the contact or you can grab from civicrm_contact.created_date using mysql.</p>
  <p>If the dates are changing than it means those contact are created via Bots. Could check all the forms which are accessible to anonymous user have recaptcha installed these includes user registration, membership signup or event registration etc? Include recaptcha on all your Civi profile forms. Visit the permission page to check if anonymous user is allowed to create contact.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-01T15:36:37.440Z
Answers.Text: I've checked a handful of the contacts I know I had already deleted and yes the contacts are being created with a new date. My know how of the system is not sufficient to work out exactly how they're doing it but I've  added captcha boxes on any profile forms where it was missing. I already updated the permission page to stop anonymous users creating contracts. I will see tomorrow morning if I've blocked all the possible avenues. Thank you I really appreciate your help.
Answers.UserDisplayName: Mary M
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-01T14:28:15.517Z
Answers.LastActivityDate: 2021-04-01T14:28:15.517Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>We are using CiviCRM with wordpress and we're trying to do a data cleanse to remove any out of date and spam contacts. None of the records we're trying to delete have financial data attached. We deleted over 500 records in batches using the permanently delete function and with each deletion the message appeared saying these records have been permanently deleted. At the time of deletion the total number of records reflected that these records had been deleted but the next day these records all reappear. Can anyone tell me how to resolve this please?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-04-01T20:10:47.973Z
Comments.Text: do you have any sort of script/job that is importing contacts from somewhere else? Are they exactly the same records (ie do an export of their name/email next time before you delete and then confirm that the new ones that appear are exact match)
Comments.UserDisplayName: petednz - fuzion
Tags: <wordpress><contacts>
Title: Permanently Deleted Contact Records Keep Reappearing
ThreadText: # Permanently Deleted Contact Records Keep Reappearing
  
  (Asked by: username_0 on 2021-04-01)
  
  We are using CiviCRM with wordpress and we're trying to do a data cleanse to remove any out of date and spam contacts. None of the records we're trying to delete have financial data attached. We deleted over 500 records in batches using the permanently delete function and with each deletion the message appeared saying these records have been permanently deleted. At the time of deletion the total number of records reflected that these records had been deleted but the next day these records all reappear. Can anyone tell me how to resolve this please?
  
  **Tags:** wordpress, contacts
  
  > **Comments:**
  > **username_1**: do you have any sort of script/job that is importing contacts from somewhere else? Are they exactly the same records (ie do an export of their name/email next time before you delete and then confirm that the new ones that appear are exact match)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-10-29. Score: 4
  
  I'm sharing this as I finally found a solution to the question I posted and hopefully it may help someone else who comes across a similar situation. Our organisation is membership based, so when a user sets up a record they are completing a Wordpress form, from which CiviCRM creates a Contact record. At the same time Wordpress creates a Profile which an administrator can access through Users in the menu options. When you look at a Contact record there is a field Contact ID / User ID and each is allocated a number, one of which is a blue link which takes you to the Profile record for that member. To delete a Contact record is very straightforward, but what I didn't realise is that before deleting the Contact record (CiviCRM), you need to delete the Profile record (Wordpress). The system is programmed to create a Contact record to match each Profile record, so if you only delete the Contact record it recreates the Contact record overnight. It's actually very straightforward but it's not covered in the User manual (at least not in the section that relates to deleting Contacts) and has taken me some time to resolve.
  
  Please note, it may work differently for Drupal so it's worth checking if you are using a CMS other than Wordpress.
  
  > **Comments:**
  > **username_1**: hmm. yes it is true that a CMS user is connected to a civi record (uf_match table), but i have never seen a situation where if you delete civi user, and do not delete the CMS user (in our case Drupal), that the Civi contact is recreated. maybe a WP scenario only. The Documentation is a community resource - if you feel able to offer an edit then it could help other WP users.  
  > **username_1**: maybe a WP plugin 'does' something over night that reruns the civi record creation?  
  > **username_1**: have raised over here https://chat.civicrm.org/civicrm/pl/gwcn61pdj7nk7g8cba7dw3zk5c  
  > **username_2**: I've reproduced with just WP and Core CiviCRM.   This is intended behavior (well as designed).   Have  contact linked to a  CMS user.  delete the contact,  This should remove the uf_match entry.  permanently deleted - no contact, no entry in uf_match.  If the CMS user logins in again, CiviCRM creates a contact and adds to the uf_match table.   So if you want the CMS user gone, you need to do that manually.  The reasoning is the CMS user could have created content and we don't want to orphan content by deleting a contact.  At least that is why I never looked at changing the behavior.  
  > **username_0**: Thanks for all your responses. Yes I'm happy to edit my comment to mention that it may work differently for Drupal. Interestingly it was a post on Google relating to Drupal that drew my attention to the solution.  
  > **username_0**: Interestingly it was a post on Google relating to Drupal that drew my attention to the solution. I've been doing a data cleanse on our site over the weekend and it's definitely not a plug in that created the situation. It actually makes sense that it's the intended behaviour and I have no issue with how it works, but what would have been a huge help is if there was mention of it in the CiviCRM user guide - specifically in the section relating to deleting civi records.  
  > **username_1**: The documentation is a community effort. so, like wikipedia, if you think something is wrong or could be improved then you are welcome to do so. if that seems too daunting, then if you supply a link here to the page in question then someone else in the community may tackle it.  
  
  ---
  
  ### Answer by username_3 on 2021-04-01. Score: 0
  
  Are those real contacts? Can you check the created date against the contact? It shows up at the bottom when you view the contact or you can grab from civicrm\_contact.created\_date using mysql.
  
  If the dates are changing than it means those contact are created via Bots. Could check all the forms which are accessible to anonymous user have recaptcha installed these includes user registration, membership signup or event registration etc? Include recaptcha on all your Civi profile forms. Visit the permission page to check if anonymous user is allowed to create contact.
  
  > **Comments:**
  > **username_0**: I've checked a handful of the contacts I know I had already deleted and yes the contacts are being created with a new date. My know how of the system is not sufficient to work out exactly how they're doing it but I've  added captcha boxes on any profile forms where it was missing. I already updated the permission page to stop anonymous users creating contracts. I will see tomorrow morning if I've blocked all the possible avenues. Thank you I really appreciate your help.  
  
  ---
  
  