xoops forums

El_Jordo

Just popping in
Posted on: 2004/2/23 0:17
El_Jordo
El_Jordo (Show more)
Just popping in
Posts: 64
Since: 2003/4/23
#1

How to customize "New user registration" e-mail

As an admin, I get a "New user registration" e-mail every time a new user registers, which says, "User123 has just registered at [sitename]."

I'd like a little more information. For example:

Quote:
A new user has registered at [sitename]!

User: User123
E-mail: user123@email.net
IP: 123.45.67.8


An e-mail like that would be wonderful! But if IP isn't possible, I'd at least like the e-mail address they used to register.

Is there an easy way to add this functionality?

El_Jordo

Just popping in
Posted on: 2004/2/24 15:53
El_Jordo
El_Jordo (Show more)
Just popping in
Posts: 64
Since: 2003/4/23
#2

Re: How to customize "New user registration" e-mail

I found this block of code that seems to deal with new user registration notices. Can anybody give me a clue what to change?

Quote:
if ($xoopsConfigUser['new_user_notify'] == 1 && !empty($xoopsConfigUser['new_user_notify_group'])) {
$myts =& MyTextSanitizer::getInstance();
$xoopsMailer =& getMailer();
$xoopsMailer->useMail();
$member_handler =& xoops_gethandler('member');
$xoopsMailer->setToGroups($member_handler->getGroup($xoopsConfigUser['new_user_notify_group']));
$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
$xoopsMailer->setFromName($xoopsConfig['sitename']);
$xoopsMailer->setSubject(sprintf(_US_NEWUSERREGAT,$xoopsConfig['sitename']));
$xoopsMailer->setBody(sprintf(_US_HASJUSTREG,$myts->oopsStripSlashesGPC($uname)));
$xoopsMailer->send();
}

El_Jordo

Just popping in
Posted on: 2004/2/25 19:36
El_Jordo
El_Jordo (Show more)
Just popping in
Posts: 64
Since: 2003/4/23
#3

Re: How to customize "New user registration" e-mail

Anybody?

tl

Friend of XOOPS
Posted on: 2004/2/25 20:47
tl
tl (Show more)
Friend of XOOPS
Posts: 999
Since: 2002/6/23
#4

Re: How to customize "New user registration" e-mail

You would have to modify the template file

language/english/mail_template/adminactivate.tpl

Maybe add the followings (not tested though) to get what you want:
{IP}
{X_UEMAIL}

El_Jordo

Just popping in
Posted on: 2004/2/26 1:31
El_Jordo
El_Jordo (Show more)
Just popping in
Posts: 64
Since: 2003/4/23
#5

Re: How to customize "New user registration" e-mail

I don't think that's the right template to modify. My user registration doesn't require admin activation. And the e-mail that goes out to admins when admin activation is off doesn't seem to have a template. It all seems to come from the code I posted above.

Good suggestion, though. I wish it were that easy.

tl

Friend of XOOPS
Posted on: 2004/2/26 2:50
tl
tl (Show more)
Friend of XOOPS
Posts: 999
Since: 2002/6/23
#6

Re: How to customize "New user registration" e-mail

You could though follow the same philosophy and add a template, either a new one or a modified one, after the following line.

Quote:
if ($xoopsConfigUser['new_user_notify'] == 1 && !empty($xoopsConfigUser['new_user_notify_group'])) {



I think the codes are all there; you just need to tinker with it. Back up the original file if you are planning to.


El_Jordo

Just popping in
Posted on: 2004/3/4 15:13
El_Jordo
El_Jordo (Show more)
Just popping in
Posts: 64
Since: 2003/4/23
#7

Re: How to customize "New user registration" e-mail



I think I'm in over my head now... I'll just put up with the lack of information I guess.

But in future releases, this would be a great added feature.

kahumbu

Documentation Writer
Posted on: 2004/4/17 16:37
kahumbu
kahumbu (Show more)
Documentation Writer
Posts: 277
Since: 2003/8/23
#8

Hack

I had the same idea, so after not finding any solution, I decided to dig in the code.

This hack will let you receive username, email and IP of the new user (if you wanted to receive notifications on new registration).

First, make a new file regnotify.tpl in language/english/mail_template/ containing this text:
new user has registered:

Username: {USERNAME}
Email: {USEREMAIL}
User IP: {USERIP}


You could change that, of course, but keep those {variables}.

Second, open up register.php and add the hack around Line 266-267:
$xoopsMailer->useMail();
[
b]// Start of Hack[/b]
$xoopsMailer->setTemplate('regnotify.tpl');
$xoopsMailer->assign('USERNAME'$myts->oopsStripSlashesGPC($uname));
$xoopsMailer->assign('USEREMAIL'$myts->oopsStripSlashesGPC($email));
$xoopsMailer->assign('USERIP'$myts->oopsStripSlashesGPC($HTTP_SERVER_VARS['REMOTE_ADDR'] ));
[
b]// End of Hack[/b]
$member_handler =& xoops_gethandler('member');


Finally, comment out this line:
//$xoopsMailer->setBody(sprintf(_US_HASJUSTREG,$myts->oopsStripSlashesGPC($uname)));


I would like to get comments from the devs about using the $myts->... syntax with the REMOTE_ADDR var. I was just going along with the syntax of the other vars. I'm not exactly sure if I needed to do that.

For now, it works on my site. Hope this helps others. Feedback appreciated.

El_Jordo

Just popping in
Posted on: 2004/4/17 17:12
El_Jordo
El_Jordo (Show more)
Just popping in
Posts: 64
Since: 2003/4/23
#9

Re: Hack

Perfect! That's absolutely what I wanted, and it works perfectly.

Thanks so much!

Dave_L

XOOPS is my life!
Posted on: 2004/4/17 17:53
Dave_L
Dave_L (Show more)
XOOPS is my life!
Posts: 2277
Since: 2003/11/7
#10

Re: Hack

Quote:
I would like to get comments from the devs about using the $myts->... syntax with the REMOTE_ADDR var. I was just going along with the syntax of the other vars. I'm not exactly sure if I needed to do that.


I don't think it's necessary, since $HTTP_SERVER_VARS['REMOTE_ADDR'] probably won't contain any backslashes (\), but it shouldn't hurt anything.

That function simply calls the PHP function stripslashes.

But in new code, it's better to use $_SERVER['REMOTE_ADDR'].