Extension:New User Email Notification

The New User Email Notification extension sends a customisable email to specified recipients when a new user account is created. The extension can send to multiple users, and additional email addresses, and is useful for keeping track of account creation on a small wiki.

Requirements
The New User Email Notification extension is available for MediaWiki 1.5.0 and later.


 * For MediaWiki 1.11.0 and above, use the trunk version
 * For the MediaWiki 1.5, 1.6 and 1.7 series, use the branched version
 * For the MediaWiki 1.8, 1.9 and 1.10 series, use the branched version

Installation

 * 1) Place extension files into a "NewUserNotif" directory in your MediaWiki "extensions" directory
 * 2) Add the line   to LocalSettings.php

Installation can be verified through the Special:Version page on the wiki.

Release Notes

 * 1.5.2 Allows you to add to or modify the parameters passed to both the email subject line and the body without modifying the extension code.

Configuration
The behaviour of the extension, including notification recipients, is managed using the configuration variables below:

$wgNewUserNotifTargets : Array containing the usernames or identifiers of those who should receive a notification email; defaults to the first user (usually the wiki's primary administrator) $wgNewUserNotifEmailTargets : Array containing email addresses to which a notification should also be sent

$wgNewUserNotifSender : Email address of the sender of the email; defaults to the value of $wgPasswordSender

Customising the notification email
The subject and text of the notification email sent to each recipient can be customised using two messages:

MediaWiki:Newusernotifsubj
Subject line

MediaWiki:Newusernotifbody
Body text

Advanced Configuration (Version 1.5.2 and later)
As of version 1.5.2 of this extension, you can customize and add parameters passed to both the subject and body messages in your localsettings.php without modifying the extension code.

You can do this by adding (or changing) parameter values and/or functions that return the desired parameter values to the parameter definition arrays underneath the call to the extension file. In both cases you can use references to $this, $user (created user object), $recipient (target), or from globals $wfContLang, $wgSitename. (For advanced techniques and using other globals, see below).

$wgNewUserNotifSenderSubjParam : The list of evaluated parameters passed to the message subject(MediaWiki:Newusernotifsubj). Default is:

$wgNewUserNotifSenderParam : The list of evaluated parameters passed to the message body(MediaWiki:Newusernotifbody). Defaults are:

You can then either edit MediaWiki:Newusernotifbody to make use of the new parameters (e.g. add "\n\nThe request came from $7.") or alternatively if you haven't customised the message you can edit NewUserNotif.i18n.php and make the change there to avoid creating a new wiki page (e.g. if your wiki is in English, change the 'en' array.)

Upgrading from 1.5.1
If you did not customize the passed parameters, this extension works exactly as before and no action need to be taken.

If you added to or changed the default passed parameters, you will need to correspondingly add to or change the corresponding arrays. You should be able to take the exact same code and add to or replace it in the arrays.

For example, if you added a 7th parameter (in his case, the email address of the new user), you would just add it (in localsettings.php, below the extension reference) like this:

The code for the parameter to be passed should be exactly the same (except enclosed in quotes) as it is in your modified wfMsgForContent function call found in private function makeMessage.

Examples For Adding Additional Parameters
Here are some commonly used additional parameter you could add to further customize your notification message subject and body:

Of course if you wanted to pass these parameter(s) to the subject message, you would add them to the $wgNewUserNotifSenderSubjParam array instead of the $wgNewUserNotifSenderParam array.

Some Technique/Tricks for Adding Additional Parameters
Let's say you wanted to use a global variable or reference other than $this, $user (created user object), $recipient (target), $wfContLang, or $wgSitename.

You could do so by directly referencing a previously assigned global. Example:

Note: This isn't the best example, because it would be easier to use the $user object ('$user->getEmail'), but it gives you an idea how you could reference the global variable (in this case objec) $wgUser directly.

Advanced Customization Prior to 1.5.2
If you want to change the parameters passed in a version prior to 1.5.2, you would need to modify the extension code directly in wfMsgForContent function call found in private function makeMessage of NewUserNotif.class.php.

Feedback
Bugs and enhancement requests should be submitted through bugzilla for the MediaWiki Extensions at:

https://bugzilla.wikimedia.org/enter_bug.cgi?product=MediaWiki%20extensions

For comments and discussion, see:

http://www.mediawiki.org/wiki/Extension_talk:New_User_Email_Notification