-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwordpress_civicrm_tokenValuesalues
39 lines (33 loc) · 1.73 KB
/
wordpress_civicrm_tokenValuesalues
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// search up values and attribute to the defined tokens
function wordpress_civicrm_tokenValues(&$details, $contactIDs, $jobID = null, $tokens = array(), $className = null) {
civicrm_initialize();
foreach ($contactIDs as $cid) {
// nested api call to grab custom yahrzeit fields based on relationship type 'Yahrzeit observed in memory of', wrapped in try-catch block so a bad call by user won't break site
// try{
$result = civicrm_api3('Relationship', 'getsingle', array(
'sequential' => 1,
'contact_id_b' => $cid,
'relationship_type_id' => 10,
'api.Contact.getsingle' => array('id' => "\$value.contact_id_a", 'return' => array('custom_22', 'custom_21', 'custom_19', 'custom_18','custom_23','custom_24','custom_25','custom_26')),
'options' => array('limit' => 1),
'is_active' => 1,
));
// var_dump($result2);
// var_dump($details);
// var_dump($contactIDs);
//var_dump($result);
//exit;
$details[$cid]['yahrzeitinfo.custom_22'] = date('F j, Y', strtotime($result[custom_22]));
$details[$cid]['yahrzeitinfo.custom_21'] = $result[custom_21];
$details[$cid]['yahrzeitinfo.custom_19'] = $result[custom_19];
$details[$cid]['yahrzeitinfo.custom_18'] = $result[custom_18];
$details[$cid]['yahrzeitinfo.custom_23'] = $result[custom_23];
$details[$cid]['yahrzeitinfo.custom_24'] = $result[custom_24];
$details[$cid]['yahrzeitinfo.custom_25'] = $result[custom_25];
$details[$cid]['yahrzeitinfo.custom_26'] = date('F j, Y', strtotime($result[custom_26]) ) ;
/*
$details[$cid]['yahrzeitinfo.deceased_first_name'] = $result2[deceased_first_name];
$details[$cid]['yahrzeitinfo.deceased_last_name'] = $result2[deceased_last_name];
*/
}
}