ryancramerdesign / LoginRegister

ProcessWire 3.x module for rendering and processing login, user registration, and profile edits.
24 stars 8 forks source link

Admin notification? #21

Open mymurkas opened 5 years ago

mymurkas commented 5 years ago

It would be so good if it could be an option för admins to get a notification as soon as someone conferms their registation. Could this be added? Thanks for a great plugin.

WebWorkingMan commented 5 years ago

In site/ready.php you can do so with a hook:

<?php  /*** Send out email when user is created via LoginRegister Module ***/  

 $wire->addHookBefore('LoginRegister::createdUser', function($event) {
     $u = $event->arguments[0];
     $confirmURL = $this->wire('pages')->get("/")->httpUrl() . "manager/access/users/";

     $mail = WireMail();
     $mail->subject(__("New user registration")); // E-Mail subject for email to administator when user registerd 
     $mail->to(array("mail@mail.com"));

     $body = "<p>".__("A new user has finished the registration process.")."</p>"; // E-Mail body for email to administator when user registerd 
     $link = "<p><a href=\"$confirmURL\">Open user management</a>";

     $mail->body(strip_tags($body). "\n\n$confirmURL");
     $mail->bodyHTML($body.$link);

     return $mail->send();

});

But yes, I agree with you, that it would be nice to have such a functionality build in.