Hi,
I am working on a new project with front-end users, and using the Userskit as a starting point. I have the code shown below, which registers “applicants”, and all is working great. Now I need to send an email to the applicant to notify them their application has been recieved. Fine for this to be plain text for now, just trying to get it working. Where should I be putting the code block from here into my code to get that email sent?
Thanks for any help!
Mike
apply-signin.php (controller)
<?php
return function ($kirby) {
if($kirby->user()) go('/');
$error = null;
$success = null;
if($kirby->request()->is('POST') and get('application')) {
try {
$password = esc(get('password'));
$validate = esc(get('validate'));
if(v::same($password, $validate)) {
$kirby->impersonate('kirby');
$user = $kirby->users()->create([
'name' => esc(get('schoolname')),
'email' => esc(get('email')),
'password' => esc(get('password')),
'language' => 'en',
'role' => 'applicant',
'content' => [
'schoolType' => esc(get('schooltype')),
'schoolContactName' => esc(get('schoolcontactname')),
'schoolContactPhone' => esc(get('schoolcontactphone')),
]
]);
$success = 'The user "' . $user->name() . '" has been created';
} else {
$error = 'Please note, passwords must be identical!';
}
} catch(Exception $e) {
$error = $e->getMessage();
}
}
return compact('error', 'success');
};