CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Deleting contacts
Pages: [1]

Author Topic: Deleting contacts  (Read 983 times)

agalligani

  • I’m new here
  • *
  • Posts: 1
  • Karma: 0
  • CiviCRM version: 2
  • CMS version: Drupal 6
  • MySQL version: 2
  • PHP version: 5
Deleting contacts
April 11, 2012, 12:13:09 pm
Hi -

I have a client who has imported a bunch of junk into the contact tables and there are tons of duplicates. I have written some php in a Drupal module that pulls up the duplicates based on having the same email and then this gives the option to merge them in civi.

I also have the need to create  a process which deletes the contact records, but I don't want to leave related records in other tables (ie. groups, address... etc). Can someone quickly explain an easy way to do this? In other words would it be best to simply delete from each table contact_id = '123' for example and then delete the contact record?

And if that works, which I have no reason to doubt, is there a list of which tables in civi might contain the contact_id as a foreign key?

If there is a function or method in the api that already does this please let me know - otherwise I can do this using PHP/MySQL.

Thanks

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Deleting contacts
April 11, 2012, 02:53:40 pm
Api contact delete seem to be what you want (and would take care of deleting related records on all the tables)

http://svn.civicrm.org/civicrm/trunk/api/v3/examples/ContactDelete.php

It would be great if you can remember why you didn't find this answer in the documentation and help fixing it.

X+

PS. It doesn't delete the contacts but put them in the trash (if you have the default config to use the trash). You can then delete them permanently
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Deleting contacts
April 12, 2012, 12:32:49 pm
If you set

$params['skip_undelete'] => 1;

then it will bypass the trash
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Deleting contacts

This forum was archived on 2017-11-26.