Extension talk:New User Email Notification

Archived discussions can be found here

Add a Name to mail reciptients listed in $wgNewUserNotifEmailTargets edit

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)Reply


Users not getting confirmation email edit

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)Reply

Doesn't work in conjunction with LDAP Authentication Plugin edit

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)Reply

The fix — possibly inelegant — is to add the wfRunHooks line in SpecialUserLogin.php.
	/**
	 * Actually add a user to the database.
	 * Give it a User object that has been initialised with a name.
	 *
	 * @param $u User object.
	 * @param $autocreate boolean -- true if this is an autocreation via auth plugin
	 * @return User object.
	 * @private
	 */
	function initUser( $u, $autocreate ) {
		global $wgAuth;
		$u->addToDatabase();
		wfRunHooks( 'AddNewAccount', array( $u ) );

Problem with getting IP edit

Here is my makeMessage function:

	private function makeMessage( $recipient, $user ) {
		global $wgSitename, $wgContLang, $wgContIP, $wgContEmail;
		return wfMsgForContent(
			'newusernotifbody',
			$recipient,
			$user->getName(),
			$wgSitename,
			$wgContLang->timeAndDate( wfTimestampNow() ),
			$wgContLang->date( wfTimestampNow() ),
			$wgContLang->time( wfTimestampNow() ),
                        $wgContIP->wfGetIP(),     # $7 = IP
                        $wgContEmail->getEmail()  # $8 = email address
		);
	}

However, I get this error:

Fatal error: Call to a member function wfGetIP() on a non-object
in /homepages/xx/dxxxxxxxx/htdocs/w/extensions/NewUserNotif/NewUserNotif.class.php on line 100

(I use One&One).

Any ideas? -- PhantomSteve/talk|contribs\ 08:57, 18 June 2010 (UTC)Reply

Re:Problem with getting IP --jdpond 11:38, 18 June 2010 (UTC) edit

You forgot to declare $wgContIP as global (see above corrected)
Thanks for that, Jpond, but I'm still getting the same error! Here is a copy from my current LocalSettings.php file (copy and pasted directly):
          #New User Notif
          require_once( "{$IP}/extensions/NewUserNotif/NewUserNotif.php" );
          # $wgNewUserNotifTargets = array (All-Changes) : 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
And here is what I have in my current NewUserNotif.class.php (copy and pasted directly):
	private function makeMessage( $recipient, $user ) {
		global $wgSitename, $wgContLang, $wgContEmail;
		return wfMsgForContent(
			'newusernotifbody',
			$recipient,
			$user->getName(),
			$wgSitename,
			$wgContLang->timeAndDate( wfTimestampNow() ),
			$wgContLang->date( wfTimestampNow() ),
			$wgContLang->time( wfTimestampNow() ),
                        wfGetIP(),          # $7 = IP
                        '$user->getEmail()' # $8 = email address
		);
	}
I also tried changing the line to
$wgContIP->GetIP(),
but I still get the same error message, but with GetIP() instead of wfGetIP() in the error message -- PhantomSteve/talk|contribs\ 12:45, 18 June 2010 (UTC)Reply
Try the above. I should have looked at this before replying. wfGetIP() requires no object, there is no such thing as $wgContIP
Thanks, that got the IP working. I can't get the Email address to work, but I'll leave that for now. Thanks for all your help -- PhantomSteve/talk|contribs\ 15:55, 18 June 2010 (UTC)Reply
See above for email address - sorry should have fixed it the first time. --jdpond 17:48, 18 June 2010 (UTC)Reply

Re:Problem with getting IP --jdpond 00:47, 19 June 2010 (UTC) edit

I just released 1.5.2 - I'd had it in the can for over a year, but didn't want to do the documentation. You can download from trunk.
If you upgrade to 1.5.2, all you have to do is add the following two lines in localsettings.php below the extension inclusion:
$wgNewUserNotifSenderParam[] = 'wfGetIP()';				// $7 Submitter's IP Address
$wgNewUserNotifSenderParam[] = '$user->getEmail()';			// $8 email

Customizing Notification Message and Adding Parameters (>= 1.5.2) - An Example edit

One of the inhibitors to the adoption of MediaWiki as an Enterprise tools is the ability to vet contributers prior to their posting of information. This is especially necessary where vandilism and inappropriate postings impact directly on the reputation and brand of the community.

To avoid this, many sites have gone to a mechanism where only approved or vetted users may post. The problem here is administrative, knowing who is requesting access (creating accounts), and responding to them in a timely fashion without undue burden on the administrator who vets the editors.

This modification was made so that when a new account is created, the administrator is automatically notified. In the notification, there is a link to the userrights of that user and another "mailto" link which, when clicked, automatically creates a response email using the registered address of the requestor.

In order to do this, additional parameters were required for the email messages.

Starting with version 1.5.2, you can add additional parameters to further customize the messages. The mechanism is actually through the creation of an extension to the extension.

To do this, you need to:

  1. Add additional parameters to pass to the message generator
  2. Modify the message text body
  3. Modify the message subject body

Add Parameters to Pass to Message Generator edit

This involves creating an extension to the 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 this in your localsettings.php after you included the NewUserNotif.php for this extension.

. . .
require_once( "{$IP}/extensions/NewUserNotif/NewUserNotif.php" );
require_once( "{$IP}/extensions/NewUserNotif/[yourExtendeParamsExample].php" );
. . .

In this example, an additional 4 parameters are added:

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
$7 new account email address
$8 Site name encoded for email message
$9 Submitter's IP Address
$10 User Name encoded for email message link

Modify MediaWiki:Newusernotifbody edit

Modify the message body to use these parameters by editing MediaWiki:Newusernotifbody:

Hello $1,

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

If this is a desired user, you should approve at: {{fullurl:Special:UserRights}}/$2.

Then notify mailto:$10<$7>&subject=Account%20Approved%20for%20$8%20Access&body=A%20new%20user%20account,%20$2,%20has%20been%20approved%20on%20$8%20at%20your%20request.%0A%0AYou%20now%20have%20approved%20rights%20at%20{{urlencode:{{SERVER}}}}{{SCRIPTPATH}}%20for%20this%20wiki.%0A%0AYour%20Friendly%20Sysop

Your Friendly Sysop!

Modify MediaWiki:Newusernotifsubj edit

Modify the message subject to use aditional parameters by editing MediaWiki:Newusernotifsubj:

[$1] New user notification User:$2

[Optional] Create new extension for customizations edit

It may be desirable to put the customized php file in a separate extension directory so that the main NewUserNotif directory can be updated independently. In this case, just modify the "require_once" directive in LocalSettings.php to point to the correct directory. One such example is available here. --Quantum7 (talk) 10:28, 5 May 2017 (UTC)Reply

Does not work with 1.16 edit

Hi,

tried but no email was sent to the admin. Also the additional targets did not receive any mail.

Re: Does not work with 1.16 --jdpond 19:23, 21 April 2011 (UTC) edit

I've had trouble with this working on several service providers, among them networksolutions, but it works fine on servers to which I have local (root). I can't seem to find a consistent pattern here. Anyone have any ideas?

New User Email Notification => NewUserNotif edit

I just installed the extension in my Wiki (hope it works with my version - 19) and discovered that the directory and the line for the LocalSettings.php should not be named "New User Email Notification", as stated in the "Installation"-part of the text, but NewUserNotif, as stated in the Readme-file. Also, the download-link in the "Installation"-part did not work; I had to go via the link "tree" in the box. Maybe someone could fix this? --LiturgicaNotata (talk) 07:12, 19 September 2013 (UTC)Reply

Fatal Error edit

I have been trying to install the extension, but cannot get past the error it's throwing at me.

 "Catchable fatal error: Argument 1 passed to MailAddress::newFromUser() must be an instance of User, string given, called in xxx.xxx.xxx/includes/User.php on line 3996 and defined in xxx.xxx.xxx/includes/mail/MailAddress.php on line 59"
 

This error appears after I click the "Create your account" button when signing up for the wiki. It appears on a big white screen. But, the notify emails do get generated. When I click on the emailed link, to verify I am real, I am taken to a login screen where I place my intended test user name and password and get the wiki message: "Login error There is no user by the name "Oscar". Usernames are case sensitive. Check your spelling, or create a new account."

The user name is correct. But, the user does not appear in my user list or active list.

My Mediawiki installation is 1.24.1 --Willazilla (talk) 19:36, 18 February 2015 (UTC)Reply

Update:

Before I posted here, I'd reached out to the original developer of this extension, Rob Church. He was able to reproduce the "bug" and related it mw 1.24.1. And, he was kind enough to help with a workaround. Rob Church is, in fact, very awesome! Following is the code:

{code} require_once "$IP/extensions/NewUserNotif/NewUserNotif.php"; $wgNewUserNotifEmailTargets = array( 'me@myemail.net' ); $wgNewUserNotifTargets = array(); {code}

--Willazilla (talk) 23:18, 22 February 2015 (UTC)Reply

ExtendedParamsExample broken for php 5.4+ edit

The hooks for passing new parameter rely on passing output parameters by reference. Since 5.4+ such parameters are required to be declared in the function definition. Thus, the function definitions for the NewUserNotifSubject and NewUserNotifBody hooks should be

 function efNewUserNotifSubject ( &$callobj , &$subjectLine , $siteName , $recipient , $user )
 function efNewUserNotifBody ( &$callobj , &$messageBody , $siteName , $recipient , $user )

Neglecting the ampersands on the first two parameters causes the hooks to be ignored on my system (php 5.5).

--Quantum7 (talk) 13:31, 22 July 2016 (UTC)Reply

Return to "New User Email Notification" page.