$user->get('id')$profile = $user->getOne('Profile');
$profile->get('blocked');$id = $user->get('id');
$dbUser = $modx->getObject('modUser',$id);
$profile = $dbUser->getOne('Profile');
$email = $profile->get('email');
$fullname = $profile->get('fullname');
$before = $profile->get('blocked');
$after = $user->get('blocked');<?php
// get currently edited user
$id = $user->get('id');
$dbUser = $modx->getObject('modUser',$id);
// get some profile information
$profile = $dbUser->getOne('Profile');
// check if user was blocked and is still blocked now
$before = $profile->get('blocked');
$after = $user->get('blocked');
// email settings
$mailFrom = '[email protected]';
$replyTo = '[email protected]';
// set some defaults
$mailFromName = 'XXX';
$message = '';
$mailChunk = '';
// set unblock message chunk & subject only if user is
// currently blocked and after edit unblocked
if (($before == 1) && ($after == 0 ) ){
$mailChunk = 'userUnBlockedEmailTpl';
$subject = 'Access granted';
}
// send mail if there is a chunk defined
if ($mailChunk != ''){
$modx->setPlaceholder('fullname',$profile->get('fullname'));
$modx->setPlaceholder('email',$profile->get('email'));
$placeHolders = array('fullname' => $fullname, 'email' => $email);
$message .= $modx->parseChunk($mailChunk, $placeHolders, '[[+', ']]');
$modx->getService('mail', 'mail.modPHPMailer');
$modx->mail->set(modMail::MAIL_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,$mailFrom);
$modx->mail->set(modMail::MAIL_FROM_NAME,$mailFromName);
$modx->mail->set(modMail::MAIL_SENDER,$mailFrom);
$modx->mail->set(modMail::MAIL_SUBJECT,$subject);
$modx->mail->address('to',$email);
$modx->mail->address('reply-to',$replyTo);
$modx->mail->setHTML(true);
if (!$modx->mail->send()) {
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
}
$modx->mail->reset();
}