Automatically email site Admin when new registration occurs

Permalink
Hi guys,

I followed the steps laid out here:http://www.concrete5.org/community/forums/customizing_c5/new-user-n... to get C5 to automatically send the site admin an email when a new user registers. It's sending the email but it's not pulling the new users UN or PW into the mail.Can anyone help me out?

PassionForCreative
 
chadsmith729 replied on at Permalink Reply
chadsmith729
Stephen, please try not to double post. Now, can you show the code that you are using that sends the e-mail?

Furthermore you might want to use the hard coded $_POST values in there. I'll take a look when you post the code you are using to send the e-mail.
PassionForCreative replied on at Permalink Reply
PassionForCreative
Hi Chad,

Thanks for replying. Code is below:

site_events.php is in /config

<?php
   Events::extend('on_user_add',             /* event */
                  'ApplicationUser',         /* class */ 
                  'setupUserJoinInfo',       /* method */
                  'models/application_user.php');


notify_new_user_added.php is in /mail
<?php 
defined('C5_EXECUTE') or die("Access Denied.");
$subject = SITE . " " . t("Notification - New User Added");
$body = t("
A new user has registered on FairwayFriends.ie.
User Name: %s
Email Address: %s
", $uName, $uEmail);
foreach($attribs as $item) {
   $body .= $item . "\n";
}
$body .= t("
This account may be managed directly at
%s", BASE_URL . View::url('/dashboard/users/search?uID=' . $uID));



application_user.php is in /models
<?php 
class ApplicationUser extends Object {
  public function setupUserJoinInfo($ui)
  {  
     Loader::model('groups');
     $u = $ui->getUserObject(); 
     // add new user to groups
     $g1 = Group::getByName('unvalidated');
     if (is_object($g1)) { 
        $u->enterGroup($g1);
     }     
     // Notify admin that new user added
     $adminUserInfo=UserInfo::getByEmail("aoife@fairwayfriends.ie");
     $adminEmailAddress = $adminUserInfo->getUserEmail(); 
     $mh = Loader::helper('mail');


Hope you can help.
chadsmith729 replied on at Permalink Best Answer Reply
chadsmith729
Try to change:
", $uName, $uEmail);


to:
", $_POST['uName'], $_POST['uEmail']);


It's a shot, accessing the $_POST directly.
PassionForCreative replied on at Permalink Reply
PassionForCreative
Bingo!!!! Cheers Chad
SVijay replied on at Permalink Reply
SVijay
Hi,

In application_user.php,

You have added parameter only for username
$mh->addParameter('userName', $ui->getUserName());

and in notify_new_user_added.php

For username you should you $username variable as you set in parameter.

So in application_user.php you need to set one parameter for password and use that variable in notify_new_user_added.php.

For more details see the line 331 in concrete/block/form/controller.php and concrete/mail/block_form_submission.php.

Hope you understand