Extension talk:New User Email Notification

Add a Name to mail reciptients listed in $wgNewUserNotifEmailTargets
First of all i'd like to say "thanks" to all who work(ed) on this extension: it's really cool.

Today i set up a mailadress on my mailserver which distributes incoming mail to several other adresses. I put it into $wgNewUserNotifEmailTargets in my wiki so the new user notification is sent to it. Unfortunally The Email body says now "Hello forwarder@mywikisystem.net ...".

Maybe it is possible to use an associative array instead of the simple array, something like this:

$wgNewUserNotifEmailTargets = array ( "E-Mail forwarder member" -> "forwarder@mywikisystem.net", "anothermailforwarder member" -> "forwarder2@mywikisystem.net" )

This way, even for adresses in $wgNewUserNotifEmailTargets The mail body could contain a better title.

--Rootkid 08:49, 5 September 2008 (UTC)

Users not getting confirmation email
It seems like the servers for some of the users on my wiki aren't allowing through the confirmation email. Is there anything that can be done about this from the wiki side of things? --Pschloss 18:06, 24 July 2009 (UTC)

Add users e-mail address to the notification message
Hey, in most cases you probably don't need that, and it could even be problematic regarding the users privacy. But for certain cases, like me using a MediaWiki for an collaborative online course, I want to get the users e-mail address as soon as they register at the course wiki. Therefore I applied following changes:

In NewUserNotif.class.php I changed: 89        private function makeMessage( $recipient, $user ) { 90                global $wgSitename, $wgContLang; 91                return wfMsgForContent( 92                         'newusernotifbody', 93                         $recipient, 94                         $user->getName, 95                         $wgSitename, 96                         $wgContLang->timeAndDate( wfTimestampNow ), 97                         $wgContLang->date( wfTimestampNow ), 98                         $wgContLang->time( wfTimestampNow ) 99                 );

to this: 89        private function makeMessage( $recipient, $user ) { 90                global $wgSitename, $wgContLang; 91                return wfMsgForContent( 92                         'newusernotifbody', 93                         $recipient, 94                         $user->getName, 95                         $wgSitename, 96                         $wgContLang->timeAndDate( wfTimestampNow ), 97                         $wgContLang->date( wfTimestampNow ), 98                         $wgContLang->time( wfTimestampNow ), 99                         $user->getEmail 100                 );

Now you can put another parameter into the body text of the notification mail (MediaWiki:Newusernotifbody):

I thought I'll put this here in case somebody else needs it.

Best regards, --Bin!johnny 22:54, 27 February 2009 (UTC)

Enhancement Recommendation - Configurable Message parameters --jdpond 01:31, 25 July 2009 (UTC)
The original intent was to have customizable email notifications sent when a new user creates an account. The recommended modifications would allow the customization of which paramters are passed to the MediaWiki:Newusernotifbody and the MediaWiki:newusernotifsubj messages (body and subject respectively), and subsequently a far more flexible email message that is sent as notification. In the example, I've used a facilitated notification and approval process for users requesting access to a wiki.

The parameters passed to the email notification could be themselves parameterized and allowed to be extended/modified in the LocalSettings modifications as follows:

require_once("$IP/extensions/NewUserNotif/NewUserNotif.php"); $wgNewUserNotifSenderParam[] = '$user->getEmail';	// $7 email (example from above) $wgNewUserNotifSenderParam[] = 'wfGetIP';		// $8 IP address of server - // Suggested in "Further customisation" IP addresses $wgNewUserNotifSenderSubjParam[] = '$user->getname';	// $2 requesting user name $wgNewUserNotifSenderSubjParam[] = 'wfGetIP';		// $3 IP address of server - // Suggested in "Further customisation" IP addresses
 * Modify NewUserNotif.php to create an array of parameter statements that would be passed to the MediaWiki:Newusernotifbody and MediaWiki:Newusernotifsubj messages.
 * Modify NewUserNotif.class.php to use the arrays in NewUserNotif.php (and any other additions from LocalSettings)
 * (Example Site customization) Modify LocalSettings to add the new parameter statements (if any) for MediaWiki:Newusernotifbody message into the $wgNewUserNotifSenderParam array (escaped, or single quoted into a string) AFTER NewUserNotif.php has been included.
 * (Example Site customization) Modify LocalSettings to add the new parameter statements (if any) for MediaWiki:Newusernotifsubj message into the $wgNewUserNotifSenderParam array (escaped, or single quoted into a string) AFTER NewUserNotif.php has been included.

Hello $1,
 * (Example Site Customization) This example sends an email message with the new user information and two shortcut links that would a) Set User rights for the newly created account and b) Send an email notifying user of same. To do this, Change the MediaWiki:Newusernotifbody message to:

A new user account, $2, has been created on $3 at $4 for $2<$7>.

If this is a desired user, you should approve at: /$2.

Then notify mailto:$2<$7>&subject=Account%20Approved%20for%20$3%20Access&body=A%20new%20user%20account,%20$2,%20has%20been%20approved%20on%20%20at%20your%20request.%0A%0AYou%20now%20have%20approved%20rights%20at%20/%20for%20this%20wiki.%0A%0AYour%20Friendly%20Sysop
 * (Example Site Customization) You probably will also want to change the welcome message, MediaWiki:Welcomecreation to something like:

Welcome, $1!
Your account has been created. Don't forget to change your preferences. In order to have full access to this site, a systems operator has to approve your request. You will be notified by email when this happens.

The required changes would be:

This would be the first functional change on this extension since July 10, 2007.

Concerns about this approach
Using eval - while it is certainly not without precedent in MediaWiki, the concept of self-modifying code sends a shiver up any self respecting developer's spine. A better approach might be to enumerate the individual variables - but I'm too lazy to do that.

I have implemented and tested these changes on several of my sites and have commit access to SVN so could make this change. Also believe this is constent (and extends) robchurch's original intent of "Extension to provide a customisable email notification of new user creation" but thought I would bounce it here first.

If no one screams, will commit in the next couple of days and update the documentation.

(--jdpond 20:20, 25 July 2009 (UTC))

Re: "Further customisation" IP addresses
The method suggested in "Further customisation" for obtaining the IP address should probably be altered to use wfGetIP instead of querying $_SERVER directly; that function will deal with proxies, etc. as far as possible. 86.133.208.13 13:22, 25 July 2009 (UTC)

Doesn't work in conjunction with LDAP Authentication Plugin
 SOLVED

I have Extension:LDAP Authentication running, and this extension doesn't work. If I disable LDAP, the extension does work, so that's definitely the issue. Any ideas how to make the two cooperate together? Timneu22 13:51, 23 March 2010 (UTC)


 * The fix &mdash; possibly inelegant &mdash; is to add the wfRunHooks line in SpecialUserLogin.php.

Problem with getting IP
Here is my makeMessage function:

However, I get this error:


 * And here is what I have in my current NewUserNotif.class.php (copy and pasted directly):


 * I also tried changing the line to  but I still get the same error message, but with   instead of   in the error message -- Phantom Steve /talk &#124;contribs \ 12:45, 18 June 2010 (UTC)