Joomla 3.6 Core Override

175 views
Skip to first unread message

l...@wigginsclan.net

unread,
Jul 14, 2016, 1:05:06 AM7/14/16
to Joomla! General Development
Hi,

I have developed a custom component for a client and they needed to be able to reuse email addresses for users. As Joomla required unique email addresses, I created a system plugin that fires on the "onAfterRoute" and loads my JTableUser class instead.

I know this isn't ideal but it was the best way to achieve the end result.

I have just installed Joomla 3.6 and it is now throwing a fatal error saying I cannot redeclare the JTableUser class when I try to use anything from the . I am guessing that the original class is now being called before the onAfterRoute trigger.

class PlgSystemMyComponentOverride extends JPlugin
{
    public function __construct(&$subject, $config = array()) {
         parent::__construct($subject, $config);
     }
      public function onAfterRoute() {
         $app = JFactory::getApplication();
         $option = JRequest::getCMD('option');
         if('com_users' == JRequest::getCMD('option')) {
             require_once('path_to_my_code.php');
         }
     }
}

Is there a way to fix this in Joomla 3.6?

Thanks

Lee

Michael Babker

unread,
Jul 14, 2016, 8:43:03 AM7/14/16
to joomla-de...@googlegroups.com
Because of a change in 3.6 and how the user data is serialized into and out of the session store, the JTableUser class will be called to refresh an authenticated user's record.  So no, there is not a way for you to overload this class when authenticated users are on the site anymore because the first use of this class comes long before the first plugin event is dispatched (ironically to dispatch events the user record has to be loaded to determine what plugins should be fired for the user).

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-gene...@googlegroups.com.
To post to this group, send email to joomla-de...@googlegroups.com.
Visit this group at https://groups.google.com/group/joomla-dev-general.
For more options, visit https://groups.google.com/d/optout.

l...@wigginsclan.net

unread,
Jul 15, 2016, 7:18:20 AM7/15/16
to Joomla! General Development
Hi Michael,

Thanks for your reply. That's not good news for those that don't want unique email addresses but thanks anyway.

Lee


On Thursday, July 14, 2016 at 10:43:03 PM UTC+10, Michael Babker wrote:
Because of a change in 3.6 and how the user data is serialized into and out of the session store, the JTableUser class will be called to refresh an authenticated user's record.  So no, there is not a way for you to overload this class when authenticated users are on the site anymore because the first use of this class comes long before the first plugin event is dispatched (ironically to dispatch events the user record has to be loaded to determine what plugins should be fired for the user).
On Thu, Jul 14, 2016 at 12:05 AM, wigm...@gmail.com <l...@wigginsclan.net> wrote:
Hi,

I have developed a custom component for a client and they needed to be able to reuse email addresses for users. As Joomla required unique email addresses, I created a system plugin that fires on the "onAfterRoute" and loads my JTableUser class instead.

I know this isn't ideal but it was the best way to achieve the end result.

I have just installed Joomla 3.6 and it is now throwing a fatal error saying I cannot redeclare the JTableUser class when I try to use anything from the . I am guessing that the original class is now being called before the onAfterRoute trigger.

class PlgSystemMyComponentOverride extends JPlugin
{
    public function __construct(&$subject, $config = array()) {
         parent::__construct($subject, $config);
     }
      public function onAfterRoute() {
         $app = JFactory::getApplication();
         $option = JRequest::getCMD('option');
         if('com_users' == JRequest::getCMD('option')) {
             require_once('path_to_my_code.php');
         }
     }
}

Is there a way to fix this in Joomla 3.6?

Thanks

Lee

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-general+unsub...@googlegroups.com.

Beat

unread,
Jul 16, 2016, 11:52:00 AM7/16/16
to Joomla! General Development
Hi Lee,

Most email addresses can be duplicated by adding a + sign and a unique part to the existing email us...@example.com like this:

user+di...@example.com

That works for gmail, and most email addresses. It's an easy way to use the same email address for multiple accounts in Joomla too.

Maybe that helps your use-case, adding the + automatically in a plugin, or proposing that to your users.

Best Regards,
Beat
http://www.joomlapolis.com/
Reply all
Reply to author
Forward
0 new messages