I'm trying to send a mail when an event is added to CGCalendar.
It works fine when i add an event in frontend but not if i add an event in CGCalendar admin console.
Is it not possible to use EventAdded for the CGCalendar admin console or is it just frontend?
Another question; Is it somehow possible to include custom fields in the mail on EventAdded?
CGCalendar: Send mail on EventAdded
- Rolf
- Dev Team Member
- Posts: 7825
- Joined: Wed Apr 23, 2008 7:53 am
- Location: The Netherlands
- Contact:
Re: CGCalendar: Send mail on EventAdded
This tutorial has a different purpose, but the method is the same and might help you:
https://www.cmscanbesimple.org/blog/adm ... tification
https://www.cmscanbesimple.org/blog/adm ... tification
- + - + - + - + - + - + -
LATEST TUTORIAL AT CMS CAN BE SIMPLE:
Migrating Company Directory module to LISE
Migrating Company Directory module to LISE
- + - + - + - + - + - + -
Re: CGCalendar: Send mail on EventAdded
Thanks Rolf
I'm not sure what triggers the EventAdded from admin in your example?
This is my UDT which works fine when adding an event to CGCalendar in frontend.
Is there something missing since no email is sent if an event is added in backend?
I'm not sure what triggers the EventAdded from admin in your example?
This is my UDT which works fine when adding an event to CGCalendar in frontend.
Is there something missing since no email is sent if an event is added in backend?
Code: Select all
$config = cmsms()->GetConfig();
$website_url = $config['root_url'];
$admin_url = $website_url . "/". $config['admin_dir'];
$event_title = $params['event_title'];
$event_id = $params['event_id'];
$booking_date = date('d/m-Y H:i');
$event_date_start = $params['event_date_start'];
$subject = 'Ny pladsreservation oprettet [ID: '.$event_id.']';
$smarty_data = '{$CustomGS.Pladsreservation_email}';
$email = $smarty->fetch('eval:'.$smarty_data);
$body = "En pladsreservation er oprettet i kalenderen med titel \"".$event_title ."\" og afventer godkendelse.\r\n";
$body .= "\r\n";
$body .= "For at se eller godkende pladsreservationen, log ind i infoskærm admin: ". $admin_url . ".\r\n";
$body .= "\r\n";
$body .= "Booking oprettet: ".$booking_date ."\r\n";
$body .= "ID: ".$event_id ."\r\n";
$body .= "Titel: ".$event_title ."\r\n";
$body .= "Dato/Tid: ".$event_date_start ."\r\n";
if ( $email )
{
$mailer = new \cms_mailer;
$mailer->SetSubject($subject);
$mailer->SetBody($body);
$mailer->AddAddress($email);
$mailer->Send();
}
audit($event_id,'CGCalendar','Ny pladsreservation: '.$event_title);