Extension talk:New User Email Notification/Archives

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)