Extension:New User Email Notification
|
New User Email Notification Release status: stable |
|||
|---|---|---|---|
| Implementation | Notify | ||
| Description | Sends email notification when user accounts are created | ||
| Author(s) | Rob Church (Robchurchtalk) | ||
| Last version | 1.5.2 (2011-03-03) | ||
| MediaWiki | 1.8.0+ | ||
| Database changes | no | ||
| License | GPL | ||
| Download |
README |
||
|
|||
|
|||
| Check usage and version matrix | |||
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.
Contents |
Requirements [edit]
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 [edit]
- Place extension files into a "NewUserNotif" directory in your MediaWiki "extensions" directory
- Add the line
require_once( "{$IP}/extensions/NewUserNotif/NewUserNotif.php" );to LocalSettings.php
Installation can be verified through the Special:Version page on the wiki.
Configuration [edit]
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 [edit]
The subject and text of the notification email sent to each recipient can be customised using two messages:
MediaWiki:Newusernotifsubj [edit]
Subject line
| Parameter | Value |
|---|---|
| $1 | Site name |
MediaWiki:Newusernotifbody [edit]
Body text
| Parameter | Value |
|---|---|
| $1 | Username of the recipient |
| $2 | Username of the new account |
| $3 | Site name |
| $4 | Date/time of account creation |
| $5 | Date of account creation |
| $6 | Time of account creation |
Further Customisation [edit]
You can fully customize both the subject line and the message body, including adding new parameters which can be passed into both of those generators starting in version 1.5.2.
Further Customisation <1.5.2 [edit]
Additional fields can be added to the notification e-mail, such as the IP address the requestor by hacking the extension code. To do this, edit NewUserNotif.class.php and in the makeMessage function near the end of the file, add extra parameters to the wfMsgForContent function (for example, adding $_SERVER['REMOTE_ADDR'] will give you the new user's IP address.) The parameters continue after the default ones, so the first parameter you add will become $7.
You can then either edit MediaWiki:Newusernotifbody to make use of the new parameter (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.)
Further Customisation - 1.5.2 Forward [edit]
Starting in 1.5.2, you can extend the message customisation by using hooks added to the extension which allow you to create new subject and body text without hacking the extension code.
This involves creating an extension to the NewUserNotif extension. For this example, the extension file "ExtendedParamsExample.php" can be found in the extension distribution. It is recommended you create a copy of this file and rename it to something meaningful to your site(s).
You would then include the new extension in your localsettings.php after you included the NewUserNotif.php.
. . . require_once( "{$IP}/extensions/NewUserNotif/NewUserNotif.php" ); require_once( "{$IP}/extensions/NewUserNotif/[yourExtendeParamsExample].php" ); . . .
This available hooks are:
| Function | Version | Hook | Description |
|---|---|---|---|
| New User Email Notification | 1.5.2 | NewUserNotifBody | Create text for message body of notification email |
| 1.5.2 | NewUserNotifSubject | Create text for the subject line of the new user notification email |
An example extension that uses this is included in the distribution as ExtendedParamsExample.php. For more details, see this Customisation example.