Page 1 of 1

Using value from CustomGS in a User Defined Tag

Posted: Fri Nov 18, 2016 5:45 pm
by webform
I've set up an UDT to send an email to a predefined email address when a user submit an event in frontend to CGCalendar (Via Event Manager).

But i would like to allow the editors of the site to set the destination email whitout giving them access to the UDT.

So i've used CustomGS a text field where editors can insert the destination email. But how do i get the field value and use in the UDT?

Re: Using value from CustomGS in a User Defined Tag

Posted: Fri Nov 18, 2016 7:39 pm
by Rolf

[SOLVED] Using value from CustomGS in a User Defined Tag

Posted: Sat Nov 19, 2016 1:54 pm
by webform
Thanks! That did the trick.

It took me some time to figure out i had to use fetch to get it to work ::)

The final UDT:

Code: Select all

$event_title = $params['event_title'];
$event_id = $params['event_id'];
$event_date_start = $params['event_date_start'];
$subject = 'Ny pladsreservation oprettet [ID: '.$event_id.']';
$smarty_data = '{$CustomGS.Pladsreservation_email}';

$body = "En pladsreservation er oprettet i kalenderen med titel \"".$event_title ."\" og afventer godkendelse.\r\n";
$body .= "\r\n";

$mailer = new \cms_mailer;
$mailer->SetSubject($subject);
$mailer->SetBody($body);
$mailer->AddAddress($smarty->fetch('eval:'.$smarty_data));
$mailer->Send();