Problem with email notification when a new user registers
Permalink
Hello,
First of all I would like to say that I pretty much like Concrete5. I am a really beginner in website building, and felt like with Concrete5 things could be easier and smooth.
So here is my problem:
I wanted to be notified each time a new user will register to my website, so that I could confirm or refuse the registration.
I tried the following instructions:
1)http://www.concrete5.org/community/forums/customizing_c5/new-user-n...
2)http://www.concrete5.org/community/forums/customizing_c5/automatica...
3)http://werstnet.com/blog/a-more-useful-on-user-add-event-for-concrete-5/
If it helps someone, I can tell you that the instructions from "1)" have to be modified a bit to get it work properly and from "2)", the last comment is the best one.
Here is how I got the email sent automatically to me as soon as a new user registers, and in the email body I have the username and the useremail indicated:
In localhost/config/site.php I added these 2 lines
I created localhost/config/site_events.php
I created localhost/models/application_user.php
I created localhost/mail/notify_new_user_added.php
At this point as the user registers I receive an email, and the user gets properly registered and added to the "unvalidated" group but in the registration page, as soon as the user hits the register button, the pages loads a warning message:
Warning: Invalid argument supplied for foreach() in localhost/mail/notify_new_user_added.php on line 9
Warning: Cannot modify header information - headers already sent by (output started at localhost/mail/notify_new_user_added.php:9) in localhost/concrete/libraries/controller.php on line 333
I tried to do what is described here:http://werstnet.com/blog/a-more-useful-on-user-add-event-for-concre...
but it changes nothing the warning stills shows after a registration.
Could someone give me some help?
Thank you!
First of all I would like to say that I pretty much like Concrete5. I am a really beginner in website building, and felt like with Concrete5 things could be easier and smooth.
So here is my problem:
I wanted to be notified each time a new user will register to my website, so that I could confirm or refuse the registration.
I tried the following instructions:
1)http://www.concrete5.org/community/forums/customizing_c5/new-user-n...
2)http://www.concrete5.org/community/forums/customizing_c5/automatica...
3)http://werstnet.com/blog/a-more-useful-on-user-add-event-for-concrete-5/
If it helps someone, I can tell you that the instructions from "1)" have to be modified a bit to get it work properly and from "2)", the last comment is the best one.
Here is how I got the email sent automatically to me as soon as a new user registers, and in the email body I have the username and the useremail indicated:
In localhost/config/site.php I added these 2 lines
I created localhost/config/site_events.php
<?php Events::extend('on_user_add', /* event */ 'ApplicationUser', /* class */ 'setupUserJoinInfo', /* method */ 'models/application_user.php'); ?>
I created localhost/models/application_user.php
<?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::getByID(USER_SUPER_ID); $adminEmailAddress = $adminUserInfo->getUserEmail(); $mh = Loader::helper('mail');
Viewing 15 lines of 22 lines. View entire code block.
I created localhost/mail/notify_new_user_added.php
<?php defined('C5_EXECUTE') or die("Access Denied."); $subject = SITE . " " . t("Notification - New User Added"); $body = t(" A new user has registered on your website. User Name: %s Email Address: %s ", $userName, $userEmail); 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));
At this point as the user registers I receive an email, and the user gets properly registered and added to the "unvalidated" group but in the registration page, as soon as the user hits the register button, the pages loads a warning message:
Warning: Invalid argument supplied for foreach() in localhost/mail/notify_new_user_added.php on line 9
Warning: Cannot modify header information - headers already sent by (output started at localhost/mail/notify_new_user_added.php:9) in localhost/concrete/libraries/controller.php on line 333
I tried to do what is described here:http://werstnet.com/blog/a-more-useful-on-user-add-event-for-concre...
but it changes nothing the warning stills shows after a registration.
Could someone give me some help?
Thank you!
got the exact same problem! hope anybody can help!
Hi!
The answer has been given to me by ntgross.
Go to the file php.ini under the directory public_html
then go to the line where it is written
output_buffering = Off
and just changed it to
output_buffering = On
For me this worked perfectly, the registration proceeds and a confirmation message appears on the screen.
The answer has been given to me by ntgross.
Go to the file php.ini under the directory public_html
then go to the line where it is written
output_buffering = Off
and just changed it to
output_buffering = On
For me this worked perfectly, the registration proceeds and a confirmation message appears on the screen.
Yeahhhhhhh
Thanks so much Birdy! That was just what I needed!
Everything working perfect now!
Although I didn´t have a php.ini at first I just made one! :)
Thanks!
Thanks so much Birdy! That was just what I needed!
Everything working perfect now!
Although I didn´t have a php.ini at first I just made one! :)
Thanks!
How do you create a php.ini file?
Cos I have having the same problem.
Cos I have having the same problem.
How do you create a php.ini file?
Cos I have having the same problem.
Cos I have having the same problem.
I was in a shared hosting environment so it was in my control panel. It auto-created it with 1 click. If you are also in a shared hosting environment, consult your control panel or contact your host. This should be simple.
Looking into that now - thanks for help and sorry about double post above!
Thanks for posting this dude! I had the same exact issue and the fix worked. Thanks to all who contributed to solving this issue.
Thanks birdyx for your post,
Is there another workaround to changing the php.ini on the server by any chance.
We're on a shared hosing package and can't get access to the php.ini file by the hosing company. They say it's 'owned' by the server.
My problem is we're getting similar error messages when new user registers. Thanks in advance.
PK
Is there another workaround to changing the php.ini on the server by any chance.
We're on a shared hosing package and can't get access to the php.ini file by the hosing company. They say it's 'owned' by the server.
My problem is we're getting similar error messages when new user registers. Thanks in advance.
PK