3

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

3 Answers 3

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 = "[email protected];
            $email->subject = 'New User Registration';
            $email->body    = 'New User: '.$user->firstName.' '.$user->lastName;

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

    });
}
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

1
  • Much like its ExpressionEngine predecessor, this was a great add-on, but I would now consider it to be abandonware. Commented Sep 17, 2018 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' => '[email protected]',

(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.

2
  • 1
    I believe this will divert all email to the 'testToEmailAddress'. In other words the user will not receive an email. Commented Feb 10, 2015 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
    Commented Feb 10, 2015 at 22:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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