Skip to content

Instantly share code, notes, and snippets.

@mainakibui
Last active December 16, 2015 13:38
Show Gist options
  • Save mainakibui/5442839 to your computer and use it in GitHub Desktop.
Save mainakibui/5442839 to your computer and use it in GitHub Desktop.
Modified Jomsocial registration file to send notification emails to all users with (Recieve System Emails) active. File location ROOT/components/com_community/controllers
//go to components/com_users/views/profile/tmpl/default.php
//add after the comments
#Start never show Joomla default profile page
$app = &JFactory::getApplication();
$app->redirect(JURI::base()."path-to-jomsocial-menu-item/my-profile-page");
#Stop never show Joomla default profile page
if($type == 'registration_complete')
{
//Send notification email to administrators (Recieve system emails)
// get all users who are set to recieve system emails
$db = JFactory::getDBO();
$querySendMailRecipients = 'SELECT name, email, sendEmail, id' .
' FROM #__users' .
' WHERE sendEmail=1';
$db->setQuery( $querySendMailRecipients );
$SendMailRecipientsrows = $db->loadAssocList();
foreach ($SendMailRecipientsrows as $SendMailRrows => $SendMailRrow )
{
if ($requireApproval)
{
$message2 = JText::sprintf( JText::_( 'COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL' ), $SendMailRrow['name'], $sitename, $name, $email, $username);
}
else
{
$message2 = JText::sprintf( JText::_( 'COM_COMMUNITY_SEND_MSG_ADMIN' ), $SendMailRrow['name'], $sitename, $name, $email, $username);
}
$message2 = html_entity_decode($message2, ENT_QUOTES);
//check if HTML emails are set to ON
if ($config->get('htmlemail'))
{
$sendashtml = true;
$tmpl = new CTemplate();
$message2 = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message2);
$tmpl->set('name', $SendMailRrow['name']);
$tmpl->set('email', $SendMailRrow['email']);
$message2 = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=privacy'), false)
->set('content', $message2)
->set('copyrightemail', $copyrightemail)
->set('sitename', $config->get('sitename'))
->fetch('email.html');
}
$mail = JFactory::getMailer();
$mail->sendMail($mailfrom, $fromname, $SendMailRrow['email'], $subject, $message2, $sendashtml);
}
}
//go to components/com_users/views/registration/tmpl/default.php
//add after the comments
#Start never use joomla registration form
$app = &JFactory::getApplication();
$app->redirect(JURI::base()."path-to-jomsocial-menu-item/register");
#Stop never use joomla registration form
if($type == 'registration_complete' && ( !$requireApproval ))
{
//Send notification email to administrators
foreach ($rows as $row)
{
if ($row->sendEmail)
{
if ($requireApproval)
{
$message2 = JText::sprintf( JText::_( 'COM_COMMUNITY_USER_REGISTERED_NEEDS_APPROVAL' ), $row->name, $sitename, $name, $email, $username);
}
else
{
$message2 = JText::sprintf( JText::_( 'COM_COMMUNITY_SEND_MSG_ADMIN' ), $row->name, $sitename, $name, $email, $username);
}
$message2 = html_entity_decode($message2, ENT_QUOTES);
//check if HTML emails are set to ON
if ($config->get('htmlemail'))
{
$sendashtml = true;
$tmpl = new CTemplate();
$message2 = CString::str_ireplace(array("\r\n", "\r", "\n"), '<br />', $message2);
$tmpl->set('name', $name);
$tmpl->set('email', $row->email);
$message2 = $tmpl->set('unsubscribeLink', CRoute::getExternalURL('index.php?option=com_community&view=profile&task=privacy'), false)
->set('content', $message2)
->set('copyrightemail', $copyrightemail)
->set('sitename', $config->get('sitename'))
->fetch('email.html');
}
$mail = JFactory::getMailer();
$mail->sendMail($mailfrom, $fromname, $row->email, $subject, $message2, $sendashtml);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment