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 (Moderator: Donald Lobo) »
  • civicrm_contact_add not working properly?
Pages: [1]

Author Topic: civicrm_contact_add not working properly?  (Read 1448 times)

axlroach

  • I’m new here
  • *
  • Posts: 22
  • Karma: 0
civicrm_contact_add not working properly?
March 22, 2009, 04:02:03 pm
Hi there,

I have a question regarding civicrm_contact_add.  I'm using civicrm version 2.1.4.  After reading the docs on this function, I attempted the following:

Code: [Select]
$params = array(
          'first_name'    => $billing_first_name,
          'last_name'     => $billing_last_name,
          'email'         => $primary_email,
          'street_address' => $billing_street1,
          'state_province' => $state_province_name,
          'contact_type'  => 'Individual'
          );
$contact =&civicrm_contact_add($params);

A print_r of the $params array shows that all elements in the array are populated with the correct data:

Array
(
    [first_name] => Joe
    [last_name] => User
    [email] => joe@user.net
    [street_address] => 123 Main Street
    [state_province] => New York
    [contact_type] => Individual
)

However, when the contact is created, the only data in the contact record is the name (both first and last) and the email address.  No location (state or street address).  Am I going about this in the wrong way?  Do I need to use civicrm_location_add() instead?  The docs for civicrm_contact_add read: 'You can include data for a single primary location within the civicrm_contact_add() params by passing simple property names (email, phone, phone_type, street_address, etc.).', so it seems like this should work.  Any advice will be most appreciated!

Also, are the possible names that one can use in the $params name/value pairs listed anywhere, or are they all the same as the column names in the database?

Thanks in advance,
axlroach


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: civicrm_contact_add not working properly?
March 22, 2009, 06:08:33 pm

the docs are incorrect and need to be fixed. Can you please file an issue.

You can add it using the following format: http://forum.civicrm.org/index.php/topic,6826.0.html. You can also do a civicrm_contact_add followed by a civicrm_location_add

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: civicrm_contact_add not working properly?
March 26, 2009, 01:32:58 am
Fixed the docs.
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • civicrm_contact_add not working properly?

This forum was archived on 2017-11-26.