Previous Thread
Next Thread
Print Thread
Rate Thread
#227688 11/11/2002 12:17 AM
Joined: Oct 2002
Posts: 165
Member
Member
Offline
Joined: Oct 2002
Posts: 165
I was looking for a way to email new user registrations to the Admin even if no approval is required... just for general information review.

Any way of doing this?

Sponsored Links
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
The easiest way... if you don't wish to turn on new user approval... is to override the email that would normally get sent for users that need approval. This won't turn on the approval process... it'll just send the email to the admin anyway.

In adduser.php find this.... and remove (or comment out) the lines in Red.

code:

// ---------------------------------------------------------------------
// Now if we are manually approving user registration we need to send an
// email to all admins
[:"red"] if ($config['userreg']) {[/]
$query = "
SELECT U_Email
FROM {$config['tbprefix']}Users
WHERE U_Status = 'Administrator'
";
$sth = $dbh -> do_query($query);
while(list($adminemail) = $dbh -> fetch_array($sth)) {
if (!$adminemail) {
continue;
}
$newuser = rawurlencode($Username);
$to = $adminemail;
$header = $mailer -> headers();
$subject = "{$ubbt_lang['NEWREG']} {$config['title']}";
$msg = "{$ubbt_lang['NEWREGBODY']} {$config['phpurl']}/admin....
mail("$to","$subject","$msg",$header);
}
[:"red"] }[/]



Edit: Careful not to miss removing that last } if you remove the if. the color is tough to see on the } by itself.
I also shorteded the one line with the URL so that Dave_L doesn't have to scroll.

Hope that works for ya.

Last edited by JoshPet; 11/11/2002 12:50 AM.
Joined: Oct 2002
Posts: 165
Member
Member
Offline
Joined: Oct 2002
Posts: 165
Josh,

This did send a notice, but I was looking for a summary of user information, such as Username and email. Then I could verify that the Username is not against our guidelines.

I went to Show/Edit User and found that I could see Users that registered in ... 1 day, so that may work as well. Somewhat more manual, but there.

Thanks for the help.


Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Ah...

I've never used approval. Does it just tell you there's stuff to approve?

OK - we can go further.
Again... I didn't test.... so let me know:

code:

In adduser.php

#
# Find this:
#

// -------------------------------------
// Now we need to mail them the password
if ( ($Username) && ($Email) ) {
$to = $Email;
$header = $mailer -> headers();
$subject = "{$ubbt_lang['PASS_SUB']} {$config['title']}";
$msg = "{$ubbt_lang['PASS_BODY1']} '$ip' ....edited for length
if ($config['userreg']) {
$msg .= $ubbt_lang['NEEDAPPROVAL'];
}
mail("$to","$subject","$msg",$header);

}



#
# BELOW it, add this:
#

// -------------------------------------
// Let's send the info to the admin - JoshPet
if ( ($Username) && ($Email) ) {

// Set this to the email you want the alert to go to
$adminalertemail = "[email protected]";

$alertheader = $mailer -> headers();
$alertsubject = "A New User Has Registered: $Username";
$alertmsg .= "You have a new user at your board.\n\n";
$alertmsg .= "Username: $Username \n";
$alertmsg .= "Email: $Email \n";
mail("$adminalertemail","$alertsubject","$alertmsg",$alertheader);

}



Hope that helps!

PS = You have to insert the email address that you want the notices sent to. Wasn't sure if you wanted to use the email in the config file or not.... or a different one.

Joined: Oct 2002
Posts: 165
Member
Member
Offline
Joined: Oct 2002
Posts: 165
Jash,

That did it! Perfect!!

Thanks for the help.


Sponsored Links
Joined: Oct 2002
Posts: 165
Member
Member
Offline
Joined: Oct 2002
Posts: 165
I made the appropriate changes to this hack for v 6.2. The following is JoshPet's code as modified, and is the only the code that needs to be changes (the earlier part of this thread is not required).

#
# Find this:
#

// -------------------------------------
// Now we need to mail them the password
if ( ($Loginname) && ($Email) ) {
$to = $Email;
$header = $mailer -> headers();
$subject = "{$ubbt_lang['PASS_SUB']} {$config['title']}";
$msg = "{$ubbt_lang['PASS_BODY1']} '$ip' {$ubbt_lang['PASS_BODY2']} "$Loginname". {$ubbt_lang['PASS_BODY3']} "$pass". ";
if ($config['verify']) {
$msg .= $ubbt_lang['DOVERIFY'] ." {$config['phpurl']}/verifyemail.php?verify=$Uid-$key&Cat=$Cat";
}
elseif ($config['userreg']) {
$msg .= $ubbt_lang['NEEDAPPROVAL'];
}
mail("$to","$subject","$msg",$header);

}

#
#BELOW it, add this:
#

// -------------------------------------
// Let's send the info to the admin - JoshPet
if ( ($Loginname) && ($Email) ) {
// Set this to the email you want the alert to go to
$adminalertemail = "[email protected]";
$alertheader = $mailer -> headers();
$alertsubject = "A New User Has Registered: Username";
$alertmsg .= "You have a new user at your board.\n\n";
$alertmsg .= "Loginname: $Loginname \n";
$alertmsg .= "Displayname: $Displayname \n";
$alertmsg .= "Email: $Email \n";
mail("$adminalertemail","$alertsubject","$alertmsg",$alertheader);
}

Joined: Sep 2001
Posts: 64
Junior Member
Junior Member
Offline
Joined: Sep 2001
Posts: 64
Ok. I added the code below

Code
// -------------------------------------  added 3/25/03 by eallen<br />// Let's send the info to the admin - JoshPet<br />if ( ($Loginname) && ($Email) ) {<br />// Set this to the email you want the alert to go to<br />$adminalertemail = "[email protected]";<br />$alertheader = $mailer -> headers();<br />$alertsubject = "A New User Has Registered: $Username";<br />$alertmsg .= "You have a new user at your board.\n\n";<br />$alertmsg .= "Loginname: $Loginname \n";<br />$alertmsg .= "Displayname: $Displayname \n";       <br />$alertmsg .= "Email: $Email \n";<br />mail("$adminalertemail","$alertsubject","$alertmsg",$alertheader);<br />}  


So - I get the email but there is no user name in the subject. Initially the code in the previous post has "Username" and all that sent was the actual word "Username" in the subject. So I added the "$" like all the ther variables and that just gets me a blank.

What am I doing wrong?

Joined: Sep 2001
Posts: 64
Junior Member
Junior Member
Offline
Joined: Sep 2001
Posts: 64
I'm gonna bump this one back up. I have registration turned on and have been trying to figure out how to send the username as part of the email notification to the administrators that someone has registered. It'll prolly be something very simple, it's just eluding me right now.

I used the sample above but took it out since I don't need another email notification that some one registered.

Any ideas anyone?

Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
Find this in your adduser.php:
Code
// ---------------------------------------------------------------------<br />// Now if we are manually approving user registration we need to send an<br />// email to all admins<br />   if (($config['userreg']) && (!$config['verify'])) {<br />      $query = "<br />         SELECT U_Email<br />         FROM   {$config['tbprefix']}Users<br />         WHERE  U_Status = 'Administrator'<br />      ";<br />      $sth = $dbh -> do_query($query);<br />      while(list($adminemail) = $dbh -> fetch_array($sth)) {<br />         if (!$adminemail) {<br />            continue;<br />         }<br />         $newuser = rawurlencode($Loginname);<br />         $to      = $adminemail;<br />         $header = $mailer -> headers();<br />         $subject = "{$ubbt_lang['NEWREG']} {$config['title']}";<br />         $msg     = "{$ubbt_lang['NEWREGBODY']} {$config['phpurl']}/admin/login.php?file=approveuser.php";<br />         mail("$to","$subject","$msg",$header);<br />      }<br />   }  


Replace it with this:
Code
// ---------------------------------------------------------------------<br />// Now if we are manually approving user registration we need to send an<br />// email to all admins<br />   if (($config['userreg']) && (!$config['verify'])) {<br />      $query = "<br />         SELECT U_Email<br />         FROM   {$config['tbprefix']}Users<br />         WHERE  U_Status = 'Administrator'<br />      ";<br />      $sth = $dbh -> do_query($query);<br />      while(list($adminemail) = $dbh -> fetch_array($sth)) {<br />         if (!$adminemail) {<br />            continue;<br />         }<br />         $newuser = rawurlencode($Loginname);<br />         $to      = $adminemail;<br />         $header = $mailer -> headers();<br />         $subject = "{$ubbt_lang['NEWREG']} {$config['title']}";<br />         $msg     = "A New User Has Registered: $Loginame \n{$ubbt_lang['NEWREGBODY']} {$config['phpurl']}/admin/login.php?file=approveuser.php";<br />         mail("$to","$subject","$msg",$header);<br />      }<br />   }   <br />  


You can change the text in the line saying:
$msg = "A New User Has Registered: $Loginame \n{$ubbt_lang['NEWREGBODY']} {$config['phpurl']}/admin/login.php?file=approveuser.php";

You can use $Loginname and $Displayname to fill in the values of the new users.

Joined: Sep 2001
Posts: 64
Junior Member
Junior Member
Offline
Joined: Sep 2001
Posts: 64
ok. I added the following to adduser.php.

Code
// ---------------------------------------------------------------------       <br />// Now if we are manually approving user registration we need to send an<br />// email to all admins   <br />if (($config['userreg']) && (!$config['verify'])) {<br />        $query = "<br />                SELECT U_Email<br />                FROM   {$config['tbprefix']}Users<br />                WHERE  U_Status = 'Administrator'<br />        ";<br />        $sth = $dbh -> do_query($query);<br />        while(list($adminemail) = $dbh -> fetch_array($sth)) {<br />                if (!$adminemail) {<br />                    continue;<br />                }<br />                $newuser = rawurlencode($Loginname);<br />                $to      = $adminemail;  <br />                $header = $mailer -> headers();<br />                $subject = "{$ubbt_lang['NEWREG']} {$config['title']}";            <br />                $msg     = "A New User Has Registered: $Loginame \n{$ubbt_lang['NEWREGBODY']} {$config['phpurl']}/admin/login.php?fi<br />le=approveuser.php";<br />                    mail("$to","$subject","$msg",$header);<br />        }<br />   }    


I then registered a test account and got the same old email output.

[]A new user has registered at Living Hope Ministries. To approve this account, please visit http://forums.livehope.org/threads/admin/login.php?file=approveuser.php
[/]

Am I adding it in the right file?

Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
hatter
hatter
USA
Posts: 69
Joined: January 2001
Forum Statistics
Forums63
Topics37,575
Posts293,931
Members13,824
Most Online6,139
Sep 21st, 2024
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
Gizmo 1
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2025 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.1
(Snapshot build 20240918)