We are trying to customise email body text that gets sent when user registers. We have tried a language override (simplest option) but would like to search and replace specific {string} string with value.
According to Joomla documentation, we can override the core class using system plugin.
This is what we have done so far
1. We copied everything from /components/com_users/models/registration.php to /templates/my-template/html/code/com_users/models/registrationoverride.php
//registrationoverride.php
//php
jimport( 'joomla.application.component.model' );
require_once(JPATH_BASE . '/components/com_users/models/registration.php');
class UsersModelRegistrationoverride extends UsersModelRegistration
{
public function register($temp)
{
//where I will customise text and send the email
}
}
2. We created system plugin - changemessage (changemessage.php, changemessage.xml) with two methods
//php
class plgSystemChangemessage extends JPlugin {
public function __construct(&$subject, $config = array()) {
parent::__construct($subject, $config);
}
public function onAfterRoute(){
$app = JFactory::getApplication();
if(JRequest::getCMD('option') == 'com_users'
&& $app->isSite() == 1
&& JRequest::getCMD('task') == 'registration.register'){
//import the new class
require_once('/var/www/vhosts/http://domain.com/templates/my-template/html/code/com_users/models/registrationoverride.php');
//
}
}
}
Problem
--------------
a. New Registrationoverride class is not being used
b. System still used the core class and not the new one
Can you help us or put us in right direction to achieve this?
Thanks in advance
DHarmesh