Email notification with actual data
Posted: 2016-06-09 18:59
I am working on adding an email notifications and have got it working but the email sends only the key instead of the data for some of my fields. I need to figure out how to get it to send the actual data from other tables and not just numbers associated with that data or the email is worthless as it only has a bunch of numbers in it.
I have this code from the hooks help. I believe the problem is $value . How do I modify this code to retrieve the actual data from my fields for the email?
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";
}
@mail(
// mail recipient
"[email protected]",
// subject
"A new record needs your attention",
// message
"The following new record was submitted by {$memberInfo['username']}: \n\n".
$messageData,
// sender address
"From: [email protected]"
);
return TRUE;
}
I have this code from the hooks help. I believe the problem is $value . How do I modify this code to retrieve the actual data from my fields for the email?
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";
}
@mail(
// mail recipient
"[email protected]",
// subject
"A new record needs your attention",
// message
"The following new record was submitted by {$memberInfo['username']}: \n\n".
$messageData,
// sender address
"From: [email protected]"
);
return TRUE;
}