3

I would've thought this would be core functionality, but does it require additional plugin functionality?

6

I believe you would need a plugin for this — but the plugin can be really basic. In your plugin's main file simply add an 'init' method that listens to the 'users.saverUser' event and checks the 'isNewUser' event attribute; then prepare and send your email.

The process is outlined in this answer that sends out an email to members of a userGroup when an entry is saved. Same principle would apply, just using users.saveUser instead.

public function init()
{
    parent::init();

    craft()->on('users.saveUser', function(Event $event)
    {
        $user = $event->params['user'];
        $isNewUser = $event->params['isNewUser'];

        if ($isNewUser) {
            // Send Mail
            $email = new EmailModel();
            $email->toEmail = "user@email.com;
            $email->subject = 'New User Registration';
            $email->body    = 'New User: '.$user->firstName.' '.$user->lastName;

            craft()->email->sendEmail($email);
        }

    });
}
| improve this answer | |
3

No custom plugin necessary if you don't want to write one, as there is already one that exists to do this very task and so much more. Checkout Postmaster for Craft. https://github.com/objectivehtml/Postmaster-for-Craft-CMS

| improve this answer | |
  • Much like its ExpressionEngine predecessor, this was a great add-on, but I would now consider it to be abandonware. – James Smith Sep 17 '18 at 15:21
2

It's not perfect, but maybe a workaround until it's core or available as a plugin...

Add to the config:

'testToEmailAddress' => 'me@example.com',

(via config-settings#testToEmailAddress)

Of course, I'd set up a new email account to catch those and also a filter, but that's just me. Again, it's not optimal I realize.

UPDATE

As Douglas mentioned in the comments, this really won't work, since it is designed to route ALL emails to the 'testToEmailAddress'. However, his own answer is a much better idea, so vote that up.

| improve this answer | |
  • 1
    I believe this will divert all email to the 'testToEmailAddress'. In other words the user will not receive an email. – Douglas McDonald Feb 10 '15 at 22:35
  • Ah, well darn. Hopefully it can be added to core features soon. Seems like it wouldn't be too difficult to add. – Chad W Feb 10 '15 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.