diff --git a/components/com_users/models/registration.php b/components/com_users/models/registration.php index 061f5f2799250..d3ac7b2e7e21f 100644 --- a/components/com_users/models/registration.php +++ b/components/com_users/models/registration.php @@ -613,7 +613,7 @@ public function register($temp) // Get all admin users $query->clear() - ->select($db->quoteName(array('name', 'email', 'sendEmail'))) + ->select($db->quoteName(array('name', 'email', 'sendEmail', 'id'))) ->from($db->quoteName('#__users')) ->where($db->quoteName('sendEmail') . ' = 1') ->where($db->quoteName('block') . ' = 0'); @@ -631,17 +631,22 @@ public function register($temp) return false; } - // Send mail to all superadministrators id + // Send mail to all users with user creating permissions and receiving system emails foreach ($rows as $row) { - $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBodyAdmin); + $usercreator = JFactory::getUser($row->id); - // Check for an error. - if ($return !== true) + if ($usercreator->authorise('core.create', 'com_users') && $usercreator->authorise('core.manage', 'com_users')) { - $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED')); + $return = JFactory::getMailer()->sendMail($data['mailfrom'], $data['fromname'], $row->email, $emailSubject, $emailBodyAdmin); + + // Check for an error. + if ($return !== true) + { + $this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED')); - return false; + return false; + } } } }