Author Topic: using api to remove contact from group  (Read 366 times)

Offline usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
using api to remove contact from group
« on: June 22, 2012, 07:48:30 pm »
The most obvious (and only that I could see) option would be:

civicrm_api3_group_contact_delete (line 126)

But the API 3 page says it is deprecated, with no recommendations on what to use instead,

Any suggestions?
You did not answer the verification questions correctly - sigh

Offline Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 3235
  • Karma: 155
    • Fuzion
Re: using api to remove contact from group
« Reply #1 on: June 23, 2012, 12:20:20 am »
Use create with a 'status' => 'Removed' (which is what delete does). The reason delete is deprecated is that it implies a full delete but it actually just updates status to 'removed'
(http://civicrm.org/sites/civicrm.org/files/bugsmithing-2013-03.png)

Offline Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 3235
  • Karma: 155
    • Fuzion
Re: using api to remove contact from group
« Reply #2 on: June 23, 2012, 12:21:18 am »
Oh yeah - you mean

civicrm_api('group_contact','create',$params);

don't you? Ie. don't call the functions in the api folder directly
(http://civicrm.org/sites/civicrm.org/files/bugsmithing-2013-03.png)

Offline usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
Re: using api to remove contact from group
« Reply #3 on: June 23, 2012, 08:15:34 am »
Cheers Eileen, yes I figured out that is how you are meant to call the api, a bit of string manipulation never hurt anyone lol
You did not answer the verification questions correctly - sigh

Offline xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 3729
  • Karma: 133
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: using api to remove contact from group
« Reply #4 on: June 23, 2012, 03:04:15 pm »
Hi,

Yes it has, remember that the forum belong to the collective documentation, and you can't imagine how long we end up fighting a typo or old syntax years after it was deemed "not the proper way" :)

Offline Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1255
  • Karma: 44
    • EE-atWork
  • CiviCRM version: from 3.3.5 to 4.3
  • CMS version: Drupal 6.20 and Drupal 7
  • MySQL version: 5.5.29-0ubuntu0.12.10.1
  • PHP version: PHP 5.3.10-1ubuntu3 with Suhosin-Patch (cli)
Re: using api to remove contact from group
« Reply #5 on: June 24, 2012, 05:29:45 am »
And to make matters worse, we change 'the proper way' every now and then..... ;)
Make sure you check the latest Make It Happen initiatives!

Offline usr238496

  • I post occasionally
  • **
  • Posts: 85
  • Karma: 0
  • CiviCRM version: latest
  • CMS version: joomla2.5
  • PHP version: 5 something
Re: using api to remove contact from group
« Reply #6 on: July 04, 2012, 01:49:01 pm »
And to make matters worse, we change 'the proper way' every now and then..... ;)

Tis the best way, keep people on their toes lol
You did not answer the verification questions correctly - sigh