V8.5.4 Registration, send user success email

Permalink
Hi Folks

I need to send a success email when the account option for regsitration is set to: "On - anyone can create an account from Login page".

I have been looking around but there doesn't seem to be an option for it in concrete v8.5.4. There is only an option to send an email to the user when validation is required, but that still needs an admin to approve their account.

UPDATE: I have made an email template in the "mail" directory in the concrete folder, called "user_registration_complete.php" but can't for the life of me find were these templates are referenced.

Any ideas?

AuroraTim
 
hutman replied on at Permalink Reply
hutman
The easiest way to do this would probably be to use the on_user_activate event and send the email yourself with something like this

use \Concrete\Core\Support\Facade\Events;
Events::addListener('on_user_activate', function($event) {
    $ui = $event->getUserInfoObject();
    $mh = $this->app->make('mail');
    $mh->to($ui->getUserEmail());
    $mh->from('noreply@yourdomain.com');
    /*
     * Optionally add parameters to populate your mail template
     *
     * $mh->addParameter('uID', $process->getUserID());
     */
    $mh->load('user_registration_complete');
    $mh->sendMail();
});
AuroraTim replied on at Permalink Reply
AuroraTim
Hi Hutman

Thanks very much for the reply.

Should this go in the EventsServiceProvider.php, or maybe the zend-mail message.php file?

Sorry if this is a stupid question. I can't seem to tell where all the mail templates get referenced. Still getting to used to certain aspects of C5 ;-)

Thanks again for your time.
hutman replied on at Permalink Reply
hutman
If you have a package it should go in the package controller.
AuroraTim replied on at Permalink Reply
AuroraTim
OK, I dont have a package so I guess the register.php controller? Thanks agin, I appreciate you answering
derekairdrie replied on at Permalink Reply
derekairdrie
If you don't have a package you can add the code into \application\bootstrap\app.php file
In that file there is an example of where you can register events.
AuroraTim replied on at Permalink Reply
AuroraTim
Excellent thanks very much. I would have never have thought to look in there.

Thanks both of you for your help.

Cheers Tim