BoostN
Well-known member
I'm trying to extend the following method:
My Class:
But, I'm getting the following error:
Any pointers on my mistake?
PHP:
protected function sendEmailChangedNotice()
{
$mail = $this->app->mailer()->newMail();
$mail->setToUser($this->user)
->setTo($this->oldEmail, $this->user->username)
->setTemplate('email_changed', [
'newEmail' => $this->user->email,
'user' => $this->user,
'ip' => ($this->logIp === true ? $this->app->request()->getIp() : $this->logIp)
]);
$mail->send();
$this->notificationSent = true;
}
My Class:
PHP:
<?php
namespace BoostN\SendySync\XF\Service\User;
class EmailChange extends XFCP_EmailChange
{
protected function sendEmailChangedNotice()
{
$user = $this->user;
parent::sendEmailChangedNotice();
/** @var \BoostN\SendySync\Service\Sendy $sendyService */
$sendyService = \XF::service('BoostN\SendySync\Service\Sendy');
$currentStatus = $sendyService->getStatus($user->oldEmail);
$sendyService->deleteUser($user->oldEmail);
if($currentStatus == "Subscribed"){
//Once the old email is removed, add the new one
$userOptions = $user->getRelationOrDefault('Option');
$sendyService->addUser($user->email, $user->username);
$userOptions->fastUpdate('boostn_sendysync_option_optin', true);
}
}
}
But, I'm getting the following error:
Code:
ErrorException: [E_USER_WARNING] Accessed unknown getter 'oldEmail' on XF:User[22] src\XF\Mvc\Entity\Entity.php:178
Any pointers on my mistake?