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) »
  • API for adding groups to CiviCRM
Pages: [1]

Author Topic: API for adding groups to CiviCRM  (Read 2096 times)

sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
API for adding groups to CiviCRM
July 31, 2013, 03:15:56 am
Hi

Is there an api call to add people to a group please (table civicrm_group_contact) ?

I tried to find one but have failed.

Thanks

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: API for adding groups to CiviCRM
July 31, 2013, 06:27:26 am
That would be the 'group_contact' api.
civicrm_api3('group_contact', 'add', array('contact_id' => 123, 'group_id' => 1));
Will add contact 123 to group number 1.
Try asking your question on the new CiviCRM help site.

sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
Re: API for adding groups to CiviCRM
August 15, 2013, 02:57:35 am
Thanks for your reply, sorry for being late responding something cropped up and I had to deal with that.

I get a Fatal error: Call to undefined function civicrm_api3()

I do not get any errors using civicrm_api   but I can't find a call that adds to the civicrm_group_contact table using civicrm_api.

I am doing something wrong? I have bootstrapped civicrm do I need to do this differently?

Thanks


Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: API for adding groups to CiviCRM
August 15, 2013, 08:52:18 am
To use the new civicrm_api3 wrapper, you should upgrade CiviCRM to the latest version if you are still on 4.3.0 as your forum bio indicates. Otherwise just use civicrm_api().
Quote
but I can't find a call that adds to the civicrm_group_contact table using civicrm_api.
The example I gave you does exactly that. You need to pass an additional paramater 'version' => 3 if you are using civicrm_api() and not civicrm_api3()
Try asking your question on the new CiviCRM help site.

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API for adding groups to CiviCRM
August 15, 2013, 02:44:07 pm
actually I think you should wait until 4.3.6 is out before pushing civicrm_api3 - I think there is a bug in it
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

sabrina

  • I post occasionally
  • **
  • Posts: 30
  • Karma: 0
  • CiviCRM version: CiviCRM 4.3.7
  • CMS version: Joomla 2.5.14
  • MySQL version: MySQL 5.5.32
  • PHP version: PHP 5.4.19
Re: API for adding groups to CiviCRM
August 19, 2013, 02:09:44 am
Ok thanks that would explain why I am having trouble as I had tried the call with version=>3.

Thanks for your help.    :)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API for adding groups to CiviCRM
August 19, 2013, 02:32:25 am
so, use civicrm_api($entity, $action, array('version' => 3, ...) until 4.3.6 is released
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) »
  • API for adding groups to CiviCRM

This forum was archived on 2017-11-26.