The following example sends a notification email to an employee when a user submits a new record. The email contains the record data.
function
tablename_after_insert(
$data
,
$memberInfo
, &
$args
){
// to compose a message containing the submitted data,
// we need to iterate through the $data array
foreach
(
$data
as
$field
=>
$value
){
$messageData
.=
"$field: $value \n"
;
}
sendmail(
array
(
'to'
=>
'employee@company.com'
,
'name'
=>
'Recipient Name'
,
'subject'
=>
'A new record needs your attention'
,
'message'
=>
"The following new record was submitted by {$memberInfo['username']}: \n\n"
.
$messageData
));
return
true;
}