Joomla 1.7 - admin email notification after user registration

There are 3 user activation options in Joomla 1.6 and 1.7 (they can be found in Users > User Manager > Options > New User Account Activation):

  • None - no activation required. After registration account is activated automatically and user can login. Notification email is sent to the registered user
  • Self - user receives an email with a link to activate his account. Once activated, user can login.
  • Admin - user receives an email with a link to verify his account. Once verified, administrators (users with "Receive System Email" option enabled) receives and email with a link to activate user's account. Once activated registered user receives a notification that his account has been activated by administrator. User can now login.

As you can see administrator is only notified about new user registration only if New User Account Activation is set to Admin. If it's set to None or Self no notification email is sent to the admin account. This behaviour is different from Joomla 1.5 where administrator was always notified.

I couldn't find a suitable extension to enable administrator notifications with none activation option so had to resort to a small hack on core Joomla files. Be aware that any change to the core files may be overwritten by a Joomla update. Always document changes you make to the core files so you can quickly re-do them if required. Also make backups of all files you modify.

Step 1

Open file:
components/com_users/models/registration.php

Scroll down to the very bottom of the code

 
if ($useractivation == 1)
 return "useractivate";
 else if ($useractivation == 2)
 return "adminactivate";
 else
 return $user->id;
 }
}
 

Delete line
return $user->id;
and paste following code instead:

 
{
// ===================================================================
// My Custom Edit. Send Notify Email to Admins start
// ===================================================================
// Compile the notification mail values.
$data = $user->getProperties();
$data['fromname'] = $config->get('fromname');
$data['mailfrom'] = $config->get('mailfrom');
$data['sitename'] = $config->get('sitename');
$data['siteurl'] = JUri::base();
 
$db = $this->getDbo();
 
$emailSubject = JText::sprintf(
'COM_USERS_EMAIL_REGISTRATION_NOTIFY_SUBJECT',
$data['name']
);
 
$emailBody = JText::sprintf(
'COM_USERS_EMAIL_REGISTRATION_NOTIFY_BODY',
$data['name'],
$data['email'],
$data['username']
);
 
// get all admin users
$query = 'SELECT name, email, sendEmail' .
' FROM #__users' .
' WHERE sendEmail=1';
 
$db->setQuery( $query );
$rows = $db->loadObjectList();
 
// Send mail to all superadministrators id
foreach( $rows as $row )
{
$return = JUtility::sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBody);
 
// Check for an error.
if ($return !== true) {
$this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));
return false;
}
}
// ===================================================================
// My Custom Edit End
// ===================================================================
 
return $user->id;
}
 

Note: We deleted line: return $user->id; and added it back at the end only because the whole code after else now has to be in between curly brackets { and }

Step 2

Now open file language/en-GB/en-GB.com_users.ini
Note: en-GB refers to a Joomla Language. If you use different language this may be different for you

At the end of the file add following lines:
COM_USERS_EMAIL_REGISTRATION_NOTIFY_SUBJECT="New user registration details (%s)"
COM_USERS_EMAIL_REGISTRATION_NOTIFY_BODY="Hello administrator,\n\nA new user has registered.\nThis email contains their details:\n\n Name :  %s \n email:  %s \n Username:  %s "

Obviously you can edit the text so it works best for you.

Now, after user registration (if New User Account Activation option is set to none) all admins with Receive System emails set to Yes will receive email notifications.

This was tested on Joomla 1.7, but should also work on Joomla 1.6.

Update: January 2012 - Joomla 2.5 released

Good news! Joomla 2.5 now got this functionality built in, so there is no need or any core hacks or third party add-ons. Simply go to User Manager > Options and set Notification Mail to Administrators to Yes

Joomla 2.5 User Manager > Options

Comments  

nixa_chez
# nixa_chez 2012-07-03 08:41
Hi..im using joomla 2.5 I set the user manager -> options New User Account Activation "Admin".. I would like to send an activation link and an email verification for the admin if a new user will register in the front-end.

If the new users will be added in the back-end only an activation link will be emailed..no more emails will be send to admin for verification. Im using userport to import users..

Is it possible?
Rogério
# Rogério 2012-03-23 13:34
I have a different problem...
When a new user creates an account from the frontend registration form every
registered user receives an email notification that should be sent only to
super users and admins.
Here is the tracker on joomlacode.org:
joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_id=8103&tracker_item_id=28291
admin
# admin 2012-03-23 13:44
Any chance all your registered users have "Receive System E-mails" set to Yes?
djidj
# djidj 2012-02-22 11:13
Hi all,
I haven't try yet, but in joomla if you edit the admin user, you can check the box
"Receive System emails"

Is that working?


thank

djidj
admin
+2 # admin 2012-02-22 16:34
This would only work in Joomla 2.5 if you also enable Notification Mail to Administrators in User Manager as explained in January 2012 update.
Steve
# Steve 2012-01-13 22:36
Hi Guys,

Check this component out, I purchased and tried it. It works great, easy to change email without do any programming. Just use HTMl editor to change email contents.
http://www.powerfulemaileditor.com/

You can also send new user email to admin.

Steve,
Anzar
# Anzar 2011-12-26 09:36
I have to add more fields in admin e-mail notfication but in joomla 1.5 .

but i dnt know which file contains the e-mail notification source for admin. plz help me
Dale
# Dale 2011-12-20 03:38
Will this work with New User Account Activation set to "self"????

I would like to have admins notified of new registrations.

Thanks
admin
# admin 2011-12-20 09:55
Yes, but you need to paste the code in if ($useractivatio n == 1)section replacing return "useractivate";

Also change return $user->id; to return "useractivate"; (in the pasted code)
Dale
# Dale 2011-12-29 23:42
THANKS!

With a few trial and errors I got your code to work!

:lol:
Richard
# Richard 2011-12-08 15:03
Thanks so much. Worked great with variation suggested to Bob P. Merry Christmas!!
Paolo
# Paolo 2011-11-30 04:40
Hello There, my question It is possible to receive the same User Register Mail on J1.7??

Thanxx
admin
# admin 2011-11-30 09:06
What do you mean? This is for Joomla 1.7
Sergio
+1 # Sergio 2011-11-16 10:59
Thank you very much, very nice workaround!
poco06
-1 # poco06 2011-11-03 07:29
Hello,

Thanks a lot for the info. I have a specific request : I would like to suppress the activation mail send by Joomla 1.7 to the users when they register (my registration process is managed with Seblod form and I don't need the joomla standard mail. User activation is set to none).
What is the file I need to modify for that (the mail I want to suppress has the following subject : Account Details for new_user at site_name).
Many thanks in advance.
Huw
-1 # Huw 2011-10-20 12:36
Wouod it be possible to modify this to email all managers/admini strators when self is selected?
rsd
+2 # rsd 2011-09-13 19:13
Yes, works on J1.6.
Thanks a lot.
Bob P
# Bob P 2011-10-06 03:34
Would it be possible to modify this to work with "Self" selected?
admin
# admin 2011-10-11 09:26
Can’t see why not…
Just paste the code in if ($useractivatio n == 1) section in place of return "useractivate";
And replace return $user->id; with return "useractivate"; (in pasted code)

Newsletter

Subscribe to receive occasional updates on new posts.
Your email will not be used for any other purpose and you can unsubscribe at any time.
Please wait