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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • crm_update_contact $params format
Pages: [1]

Author Topic: crm_update_contact $params format  (Read 1125 times)

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
crm_update_contact $params format
July 29, 2007, 12:02:35 am
I'm hoping to pass data for two additional locations into crm_update_contact.

Here's what I'd like to do:
Code: [Select]
  $account = user_load(array('uid'=>'1234')) ; // i'm using drupal. load the user account.
 
  $params = array(
  'first_name'    => 'Chris',
  'last_name'     => 'Burgess',
  'email'         => 'xuriz...@gmail.com',
  'street_address'=> '',
  'country'       => 'NZ',
  'locations' => array(
       'Work' => array(
       'phone' => '12123456',
       'phone_type' => 'Mobile'
       ),
       'Home' => array(
       'phone' => '12123456',
       'phone_type' => 'Phone'
       ),
       ),
  );

  if ( !is_null($account) && isset($account->uid) ) {
    $cid = crm_uf_get_match_id($account->uid) ;
    if ( $contact =& crm_get_contact(array('contact_id'=>$cid)) ) {
      if ( !is_a( $contact, 'CRM_Core_Error' ) ) {
$contact =& crm_update_contact($contact, $params) ;
      }
    }
  }

All of this works, except the two phone numbers aren't stored against the corresponding locations. Looking at _crm_update_contact, it seems like it does scan the key 'locations' of the $params array, and should store details there if I format them correctly. Am I just missing the correct format?
@xurizaemon ● www.fuzion.co.nz

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: crm_update_contact $params format
July 30, 2007, 03:51:31 pm
Which version / rev of CiviCRM are you running?

Can you try coding your update call against the "V2" API in 1.8: civicrm_contact_add

You can find example(s) of using the V2 API's in our unit tests directory in svn:
http://svn.civicrm.org/branches/v1.8/test-new/SimpleTest/api-v2/

If the problem persists - please post a bug report in the issue tracker against 1.8, including your code snippet.
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • crm_update_contact $params format

This forum was archived on 2017-11-26.