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?
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?
Hi Chad,
Thanks for replying. Code is below:
site_events.php is in /config
notify_new_user_added.php is in /mail
application_user.php is in /models
Hope you can help.
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');
Viewing 15 lines of 21 lines. View entire code block.
Hope you can help.
Try to change:
to:
It's a shot, accessing the $_POST directly.
", $uName, $uEmail);
to:
", $_POST['uName'], $_POST['uEmail']);
It's a shot, accessing the $_POST directly.
Bingo!!!! Cheers Chad
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
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
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.