I was able to set up something similar. When a registered user is marked 'Enabled' by an admin it emails the registered member.
I'm not sure how you are trying to do this, but inside my MediaMember.php I have a onAfterWrite() function that handles the emailing. the parent::onAfterWrite() handles everything else.
class MediaMember extends DataObjectDecorator {
...
function onAfterWrite() {
if($this->checkStatus == 'Disabled' && $this->owner->Status == 'Enabled') {
if($this->selUser->inGroup('media-access')) {
$email = new Email();
$email->setTo($this->owner->Email);
$email->setSubject('Account Enabled');
$email->setFrom('no_reply@mysite.com');
$email->setTemplate('AccessGranted');
$email->populateTemplate($this->owner);
$email->send();
}
}
parent::onAfterWrite();
}
}
you shouldn't have to call the member's dataObject as you are in the DataObjectDecorator which references the Member you are currently editing. $this->owner is the member's dataobject.