Skip to content

Commit

Permalink
second try
Browse files Browse the repository at this point in the history
  • Loading branch information
brianteeman committed Feb 10, 2022
1 parent eb70adc commit 881f25e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions components/com_users/models/registration.php
Expand Up @@ -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');
Expand All @@ -631,17 +631,22 @@ public function register($temp)
return false;
}

// Send mail to all superadministrators id
// Send mail to all users with users 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);

return false;
// Check for an error.
if ($return !== true)
{
$this->setError(JText::_('COM_USERS_REGISTRATION_ACTIVATION_NOTIFY_SEND_MAIL_FAILED'));

return false;
}
}
}
}
Expand Down

0 comments on commit 881f25e

Please sign in to comment.