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) »
  • Updating first and last names
Pages: [1]

Author Topic: Updating first and last names  (Read 811 times)

jimurl

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 0
  • CiviCRM version: 3.4.6
  • CMS version: drupal 6.22
  • MySQL version: 5+
  • PHP version: 5+
Updating first and last names
May 09, 2011, 02:43:17 pm
Is it possible to use the API to update first and last names of contacts? It appears that, since they are using in matching to to a contact, they cannot be overwritten- is that correct?

If I try this :

<code>
$data = array(
            'contact_id'    => $civiid,
            'contact_type'  => 'Individual',
            'contact_sub_type' => 'Student',
            'first_name'    => $node->field_fname[0]['value'],
            'last_name'     => $node->field_lname[0]['value'],
            'middle_name' => $node->field_mname[0]['value'],
            'sortname' => $sortname,
            'nick_name' => $node->field_nick_name[0]['value'],
            'display_name' => $displayname,
            'gender_id' => $gender,
            'birth_date' => $birthdate,           
            );
           // var_dump($data);
          $ret_val = civicrm_contact_update($data);
</code>

... I can change many fields, but not first_name and last_name.



jim

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Updating first and last names
May 09, 2011, 02:45:05 pm
It *should* be possible if you pass in the ID to change the name - You might need to do a get first to get the id
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

jimurl

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 0
  • CiviCRM version: 3.4.6
  • CMS version: drupal 6.22
  • MySQL version: 5+
  • PHP version: 5+
Re: Updating first and last names
May 09, 2011, 03:57:16 pm
You are correct. It appears to be working fine for me now; but before, no matter how I tried to trigger a change in those values, they didn't 'take.' But currently, I am seeing exactly as you describe, though I am not sure what I changed for it to begin working ...

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Updating first and last names
May 09, 2011, 03:58:08 pm
'id' vs 'contact_id'?
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

jimurl

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 0
  • CiviCRM version: 3.4.6
  • CMS version: drupal 6.22
  • MySQL version: 5+
  • PHP version: 5+
Re: Updating first and last names
May 10, 2011, 12:13:52 pm
I'm using 'contact_id'- should I be using  just 'id'?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Updating first and last names
May 10, 2011, 02:46:01 pm
Well, we are aiming to make 'id' always work - not sure if we are there yet though
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) »
  • Updating first and last names

This forum was archived on 2017-11-26.