-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleave_notifications_basic.php
More file actions
26 lines (24 loc) · 1012 Bytes
/
leave_notifications_basic.php
File metadata and controls
26 lines (24 loc) · 1012 Bytes
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
<?php
/**
* A very basic example of what you can do using TribeHR webhooks without the API.
* This uses a hard-coded array to simply send a basic email when specific TribeHR Users
* add a new LeaveRequest.
* To see how to get more information about the LeaveRequest or the adding User, look to
* more advanced examples that connect to the TribeHR API.
*/
// Create one array entry per notification rule you wish to create:
// key: adding user's ID
// value: the email address(es) to notify when the adding user creates a LeaveRequest - either a string or an array
$leaveApprovers = array(
12 => 'supervisorperson1@mycompany.com',
3 => 'supervisorperson1@mycompany.com',
5 => array('hr_manager@mycompany.com', 'ceo@mycompany.com'),
);
if (!empty($_POST['user_id']) && !empty($leaveApprovers[$_POST['user_id']])) {
mail(
implode(', ', (array)$leaveApprovers[$_POST['user_id']]),
sprintf('%s just requested some leave', $_POST['user_name']),
'You should log in to TribeHR to approve it'
);
}
?>