I have a plugin Events,
I would like to add this part
UsersController.php
private function sendResetEmail($url, $user) {
$email = new Email();
$email->template('resetpw');
$email->emailFormat('both');
$email->from('no-reply@naidim.org');
$email->to($user->email, $user->full_name);
$email->subject('Reset your password');
$email->viewVars(['url' => $url, 'username' => $user->username]);
if ($email->send()) {
$this->Flash->success(__('Check your email for your reset password link'));
} else {
$this->Flash->error(__('Error sending email: ') . $email->smtpError);
}
}
To this part
EventController (INSIDE PLUGINS)
$event = $this->Events->newEntity();
if ($this->request->is('post')) {
$event = $this->Events->patchEntity($event, $this->request->data);
if ($this->Events->save($event)) {
//function send_mail to user who crated Event
EventManager::instance()->on(
'Model.Events.afterNotify',
$aCallback
);
$this->Flash->success(__('The event has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The event could not be saved. Please, try again.'));
}
}