This documentation relates to CiviCRM version 3.2. It's not maintained anymore.
Current version of documentation.

Location APIs

Skip to end of metadata
Go to start of metadata

This page refers to outdated version of CiviCRM. Check current version of documentation.


Documentation Search


CiviCRM 3.2 Documentation

Support and Participation

Developer Resources


CiviCRM book!

Make sure to check out Understanding CiviCRM as well! You can also support this project by ordering a hard copy.

Location APIs

civicrm_location_add($params)

Availability: v1.8

Used to create additional locations for an existing contact.

Parameters:

  • 'params' (array) Associative array of property name/value pairs to insert in new location. Minimum required data values are:
    • 'location_type' - a valid location_type string (e.g. 'Home')
    • 'contact_id' - a valid contact_id whom location to be added.
    • At least one other location property name/value pair

Returns:

  • Newly created Location array.
    Email, Phone and IM values are Arrays

    A Location may have 0 : n nested Email, Phone and IM associated with it. Therefore, when creating a new Location, you must construct an array of one or more data for each of these properties.

civicrm_location_get($contact)

Availability: v3.2

Returns array of location(s) for a contact. 'return_properties' may be used to constrain the properties returned for each location. Otherwise the default set of properties are returned.

Parameters:

  • 'contact' (array) A valid Contact array containing contact parameters.

Returns:

  • An array of location parameters arrays. This will always consist of:
    • one array per location (which can contain a number of emails, a number of phones and an address)
    • within that array, possibly arrays with emails, phones and address
Example: civicrm_location_get()

 Some example code where phone numbers are retrieved:

Some example code where a specific type of email is retrieved:

civicrm_location_update($params)

Availability: v1.8

Update a specified location with the provided property values.

Parameters:

  • 'params' (array) Associative array of property name/value pairs to be updated.

Returns:

  • Location array with updated property values.
    Updating Email Addresses, Phone Numbers and IM Screennames

    When updating properties which are arrays of nested objects (emails, phones, ims), you must give an array of existing value(s) with updated value(s) as the data for that $location array element.

civicrm_location_delete(&$contact)

Availability: v1.8

Deletes a contact location.

Parameters:

  • 'contact' (array) A valid Contact array (passed by reference).
  • 'location' (array) Valid (db-level) existing value(s) location to be deleted.

Returns:

  • null, if successful.
  • CRM error, if 'contact' or 'location_id' is invalid, permissions are insufficient, etc.
Labels
  • None

Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.