Hey,
I couldn't find a UDT in the forum to automatically send an email to a new user once they have registered with SelfRegistration so I tweaked a different one I found. I thought I would post it here in case anyone else was looking for the same thing.
1. Create A UDT called "New_User" or anything you like.
2. Copy & Paste the below code into the UDT. Be sure to make the appropriate changes to tailor it for your setup. I use the standard Username as the email but you may be using something else.
if (!function_exists('MyGetModuleInstance'))
{
function &MyGetModuleInstance($module)
{
global $gCms;
if (isset($gCms->modules[$module]) &&
$gCms->modules[$module]['installed'] == true &&
$gCms->modules[$module]['active'] == true)
{
return $gCms->modules[$module]['object'];
}
// Fix only variable references should be returned by reference
$tmp = FALSE;
return $tmp;
}
}
global $gCms;
$feu = MyGetModuleInstance('FrontEndUsers');
if ($feu == FALSE)
return false;
//Get User
$feu_user = $feu->GetUserInfo($params['id']);
//Do they really exist? Why are we here anyway?
if ($feu_user)
{
//use CMSMailer module to send mail
$cmsmailer =& $gCms->modules['CMSMailer']['object'];
$cmsmailer->AddAddress($feu->GetUserName($params['id']),$feu->GetUserPropertyFull('Username', $params['id']));
$cmsmailer->SetFrom('FROM EMAIL ADDRESS HERE');
$cmsmailer->SetFromName('FROM NAME HERE');
$cmsmailer->SetBody('EMAIL MESSAGE HERE');
$cmsmailer->IsHTML(true);
$cmsmailer->SetSubject('EMAIL SUBJECT HERE');
$cmsmailer->Send();
}
3. Add the UDT to the onUserRegistered event in Event Manager.
That's it.
[SOLVED] UDT To Send Email To New User From Self Registration
Re: [SOLVED] UDT To Send Email To New User From Self Registr
Hi clj83,
I've been trying to find a UDT to send an email to Frontend users whenever their personal data is updated. I guess your UDT should work when I add it to the OnUpdateUser event?
I've tried it already, but in my case the user's email address is not in the username field, so I'm not sure where to change this in your UDT. The user's email address is in a field called "e_mail".
Could you point me in the right direction?
Thanks a lot!
I've been trying to find a UDT to send an email to Frontend users whenever their personal data is updated. I guess your UDT should work when I add it to the OnUpdateUser event?
I've tried it already, but in my case the user's email address is not in the username field, so I'm not sure where to change this in your UDT. The user's email address is in a field called "e_mail".
Could you point me in the right direction?
Thanks a lot!
UDT To Send Email To New User From Self Registration
Hi,
I've managed to get this UTD working with my particular user properties, but it would be great if I could include the user's data in the body of the e-mail.
I've looked around and tried a few things, but I haven't been able to get the user data in there...
Should be easy enough if you know how to code, but unfortunately I haven't gotten that far in my cookbook yet...
thanks,
wim
I've managed to get this UTD working with my particular user properties, but it would be great if I could include the user's data in the body of the e-mail.
I've looked around and tried a few things, but I haven't been able to get the user data in there...
Should be easy enough if you know how to code, but unfortunately I haven't gotten that far in my cookbook yet...
thanks,
wim