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.
|
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
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. |
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.