New user activation notification

Permalink
I've read about this in a couple other threads. When a user registers, our site is setup so that the admin receives an email to approve the account. Once approved, we'd like an email to go to the new user's email saying that they've been approved.

Can anyone assist me in this?

Thanks for your help!
-Dan

dcaryll
 
anchoredbutterfly replied on at Permalink Reply
anchoredbutterfly
dcaryll replied on at Permalink Reply
dcaryll
This solution is a little outdated. I can't seem to find the right way to do it within that thread. The email is being sent when someone registers but not when they've been activated.

Thanks for the response.
-Dan
anchoredbutterfly replied on at Permalink Reply
anchoredbutterfly
It's right there in the thread:

To send an email to users upon activation, copy concrete/models/userinfo.php to /models/userinfo.php. After the function activate() code (around line 540), add this code:

//send user email on activation
           $userEmailAddress = $this->uEmail;
           $mh = Loader::helper('mail');
           $mh->addParameter('userName', $this->uName);
           $mh->to($userEmailAddress);
           $mh->load('user_activation');
           $mh->sendMail();


Then create a mail template called "user_activation.php" in the mail folder.

Now your users will receive an email each time you activate them.
dcaryll replied on at Permalink Reply
dcaryll
Yes, I read that. But that code is outdated because the userinfo.php no longer has the same things in it.
anchoredbutterfly replied on at Permalink Reply
anchoredbutterfly
Then make the adjustments, is what I would suggest. Other than that, I dunno. Sorry...
adajad replied on at Permalink Reply
adajad
This is what I use in 5.6.0.2:

I created an override of 'root/concrete/models/userinfo.php' by making a copy of the file to 'root/models/userinfo.php' and edited the activate() function (line 572) to read:
function activate() {
   $db = Loader::db();
   $q = "update Users set uIsActive = 1 where uID = '{$this->uID}'";
   $r = $db->query($q);
   //Send user email on activation
    $mh = Loader::helper('mail');
    $mh->addParameter('uName', $this->uName);
    $mh->addParameter('uEmail', $this->uEmail);
    $mh->to($this->uEmail);
    $mh->load('user_activation'); //load mail template
    $mh->sendMail();
   Events::fire('on_user_activate', $this);
}


I also created the email template 'user_activation.php' in 'root/mail' which holds:

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$subject = SITE . " - Your account has been activated";
$body = "
Your account has now been activated.
Your registered username: %s
Your registered email: %s
", $uName, $uEmail);
$body .= t("
You can now login: %s
", BASE_URL . View::url(''));


Of course you can tweak the mail template to your liking, but all my users now gets an email whenever they are activated.

EDIT: Dang... never use the toilet, then your post will be old before you hit Reply. ;)
dcaryll replied on at Permalink Reply
dcaryll
Here's my full function within userinfo.php:

function activate() {
         $db = Loader::db();
         $q = "update Users set uIsActive = 1 where uID = '{$this->uID}'";
         $r = $db->query($q);
         //Send user email on activation
              $mh = Loader::helper('mail');
              $mh->addParameter('uName', $this->uName);
         $mh->addParameter('uEmail', $this->uEmail);
              $mh->to($this->uEmail);
              $mh->load('user_activation'); //load mail template
              $mh->sendMail();
         Events::fire('on_user_activate', $this);
      }


and here's my entire user_activation.php:

<?php 
defined('C5_EXECUTE') or die("Access Denied.");
   $subject = SITE . " - Your account has been activated";
   $body = "
   Your account has now been activated.
   Your registered username: %s
   Your registered email: %s
   ", $uName, $uEmail);
   $body .= t("
   You can now login: %s
   ", BASE_URL . View::url(''));


the email still doesn't seem to be going to the newly activated user.

Thanks so much for everyone's assistance.
adajad replied on at Permalink Reply
adajad
Have you checked your logfile? Do you get any emails from your site (test
with forgot password or something)?
Den 23 jan 2013 16:48 skrev "concrete5 Community" <
discussions@concretecms.com>:
dcaryll replied on at Permalink Reply
dcaryll
I have checked the logs file in the database. The emails are coming through to the admin but none are going out to the newly activated users.
adajad replied on at Permalink Reply
adajad
The c5 log in the dashboard can be a bit misleading. When viewing the log after an activation, the first entry you see is the email sent and the second entry from top is the error (if any).

Also, have you checked spam filters and junk boxes?
dcaryll replied on at Permalink Reply
dcaryll
Thanks. I've checked the logs in the C5 backend and in the database. Doesn't seem like any emails are going out to the newly registered users.

Is my code wrong?