I have made a custom module that allows a user to upload a CSV and import it using a FeedMe feed. This all works fine, however I want to send an e-mail to the user when the import has completed.
I have this so far, but realised it doesn't work because the event doesn't have access to the user session:
Event::on(Process::class, Process::EVENT_AFTER_PROCESS_FEED, function(FeedProcessEvent $event) {
$email = Craft::$app->getUser()->getIdentity()->email;
if ($event->feed->id === getenv('USER_FEED_ID')) {
$message = new Message();
$message->setTo($email);
$message->setSubject("Import complete");
$message->setHtmlBody('Data has been imported successfully');
$message->send();
}
});
I've been scratching my furry head but can't think of a solution, is there any way to do this?