New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Listener Addon not firing

Jeremy Hoover December 14, 2019 by Jeremy Hoover

I'm trying to make a listener Addon that send an email when a user account is deleted.

This is what I have, but no email is sent. I'm pretty sure the Addon isn't being triggered at all as I've tried the email sending code elsewhere and it works.


namespace Statamic\Addons\UserDeleted;

use Statamic\Extend\Listener;
use Statamic\API\Email;

class UserDeletedListener extends Listener

    public $events = [
        'UserDeleted' => 'sendEmail'

    public function sendEmail() {

        $email = \Statamic\API\Email::create();
        $email->to('[email protected]')->subject('Account Cancelled')->template('notify-admin-account-cancelled')->send();

Thanks if anyone can help.

Answered by Erin Dalzell!
>>>>>>> Answered <<<<<<<
1 Reply