This is the documentation for concrete5 version 5.6 and earlier. View Current Documentation

Admin notification on user registration/addition is built into 5.6.x; however, there's no built-in way to send a registered user when a new account is manually activated. This presents a problem, because manual activation could take minutes, hours, or days, depending on when the site administrator gets around to doing it, and the user has no way of knowing when it happens.

The following procedure might not work for every scenario or older C5 version, but it seems to work for v5.6.0.x.


1.1 Make sure your server mail function is working and sending admin mails to you. If you receive other site notifications, you're probably good to go. If not, it might work to add something like the following line to config/site.php:

define('EMAIL_DEFAULT_FROM_ADDRESS', '[email protected]');

1.2. Make sure public registration is enabled (see "Public Registration") in the Dashboard's System & Settings view), then create a dummy user with an email that you can check.

In config/site_events.php, add a line like the following:

Events::extend('on_user_activate', 'OnActivation', 'sendActivationMail', 'models/on_activation.php');

...which follows the pattern of [trigger event], [new class], [new function in new class], [path of file containing new class]. Note that there should be no closing "?>" php tag in the site_events file. If you don't already have a config/site_events.php, you can just create it.

In [root]/models/ add a new file with the name you specified in the site events line (it's "models/on_activation.php" in my previous example).

Add something like the following to the new model file:

 class OnActivation {
   public function sendActivationMail($ui) {
      $mh = Loader::helper('mail');  
      $userEmailAddress = $ui->uEmail;
      $userName = $ui->uName;
      $userFname = $ui->getAttribute('firstname');



This example includes both basic user data (username and email), plus a custom user attribute (firstname). The $mh->load variable is the file name of the email content, which you'll create next. Again, there should be no closing php tag in this fie.

In [root]/mail add a new file with the same name as the $mh->load variable in your new class.

Add something like the following to the new mail file:

$subject = t("Your My Site registration has been activated");

$body = t("

Hi, %s.

Welcome to My Site. Your account is now active with the following information:

User Name: %s
Email Address: %s
", $memFname, $memName, $memEmail);
$body .= "\n\n";
$body .= t("blah blah blah");

The variable names in this sample are those that were specified in the new class and must be listed in the same order as the %s placeholders. Also, again, no closing php tag.

Hope this works for you!

Loading Conversation