-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_user_on_deactivation.php
46 lines (35 loc) · 1.35 KB
/
email_user_on_deactivation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
// Import library dependencies
jimport('joomla.event.plugin');
class plgUserEmail_User_On_Deactivation extends JPlugin
{
function onUserBeforeSave($user, $isNew, $futureData){
//user gets blocked and was not blocked before
if(!$isNew && ($user['block'] == 0) && ($futureData['block'] == 1)){
$mailer = JFactory::getMailer();
$config = JFactory::getConfig();
$sender = array( $config->getValue('config.mailfrom'),
$config->getValue('config.fromname')
);
$mailer->setSender($sender);
$mailer->addRecipient($user['email']);
$subject = $this->params->get('subject');
$mailer->setSubject($subject);
$message = $this->params->get('message');
$message = str_replace("{name}", $user['name'], $message);
$message = str_replace("{username}", $user['username'], $message);
$message = str_replace("{lastvisit}", $user['lastvisitDate'], $message);
$message = str_replace("{replyto}", $config->getValue('config.mailfrom'), $message);
$mailer->setBody($message);
$sent = $mailer->Send();
/* not needed for now because the mailer itself raises the error messages
if($sent !== true){
JFactory::getApplication()->enqueueMessage($sent->getMessage(), 'error');
}
*/
}
}
}
?>