function _civicrm_entity_contact_assign_rel_contact_field_add_contact_relationship in CiviCRM Entity 7.2
Helper function, add a contact relationship added and set active with start date of "now"
Parameters
$contact_a_id:
$contact_b_id:
$relationship_type_id:
1 call to _civicrm_entity_contact_assign_rel_contact_field_add_contact_relationship()
- _civicrm_entity_contact_assign_rel_contact_field_process_field_items in modules/
civicrm_entity_contact_assign_rel_contact_field/ civicrm_entity_contact_assign_rel_contact_field.module - Helper function to process field items on entity insert or update
File
- modules/
civicrm_entity_contact_assign_rel_contact_field/ civicrm_entity_contact_assign_rel_contact_field.module, line 662 - Provide CiviCRM Entity Contact Assign Relationship Contacts List Field Type. Provides a widget for adding/removing a contacts relationships to a list of contacts.
Code
function _civicrm_entity_contact_assign_rel_contact_field_add_contact_relationship($contact_a_id, $contact_b_id, $relationship_type_id) {
civicrm_initialize();
try {
$start_date = date('Y-m-d');
$result = civicrm_api3('Relationship', 'create', array(
'contact_id_a' => $contact_a_id,
'contact_id_b' => $contact_b_id,
'relationship_type_id' => $relationship_type_id,
'is_active' => 1,
'start_date' => $start_date,
));
} catch (CiviCRM_API3_Exception $e) {
}
}