I am using the after_insert hook to send a notification email to organization members when there is a new first aid record created. The cde I'm using is what I copied from the tutorial on this hook (below). The issue I'm having is that the email sends the ID numeric value which is useless to the reader. I want to instead use the actual project name (we're a construction company) that the ID number refers to in the project table. I am not a coder so if you can help, please give me clear instruction of where I need to make changes if it can even be done. Thank you in advance!
///// Here is the code I'm currently using /////
function firstaid_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 FIRST AID report has been submitted",
// message
"The following FIRST AID REPORT was submitted by {$memberInfo['username']} This is raw data from the report, share it with crews.: \n\n".
$messageData,
// sender address
"From: [email protected]"
);
//end email code
return TRUE;
}
After Insert Hook - Send Email Using Field Value NOT ID
-
- Posts: 3
- Joined: 2018-01-04 18:35
Re: After Insert Hook - Send Email Using Field Value NOT ID
Hi,
please replaceby
please replace
Code: Select all
foreach($data as $field => $value){
Code: Select all
$value_data = get_joined_record('firstaid',$data['selectedID'],true);
foreach($value_data as $field => $value){
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.