Redirect no longer working since 2.5.11

67 views
Skip to first unread message

ljk

unread,
Jun 4, 2013, 4:10:47 PM6/4/13
to joomla-de...@googlegroups.com
Hi,

I am the developer of the KC VM Registration Redirect system plugin extension. What it is supposed to do is when someone trieds to go to the Joomla regististration page, it redirects you to the VirtueMart registration page.

It has been working until the Joomla 2.5.11 upgrade. Now it doesn't redirect reliably. In some cases rather than the user being taken to the VM registration page, they are taken to the Joomla login page. This seems to only happen when Joomla SEF URLs are turned on. I thought the issue was that in some cases the URL didn't have an Itemid set, so changed the plugin such that it defaulted to Itemid=0 if there wasn't a valid Itemid on the Joomla registration link. But this still is not working in some cases. It seems that if you have something in your VM cart, the link works but if the cart is empty it doesn't.

This is the code:
        function onAfterRoute()
        {
                    // Get the application object.
                    $app = JFactory::getApplication();
                   
                    if ($app->isSite()) {
                        // if this is the front end, see if this is a registration page

                        if ( $app->input->get('option') == 'com_users' ) {
                            $view = $app->input->get('view', '');
                            $itemID = $app->input->get( 'Itemid', '' );
                            // Look for a registration link to Joomla! User manager
                            if ($view == 'registration') {
                                $url = 'index.php?option=com_virtuemart&view=user';
                                $menuid = (int) $this->params->get("menuid", 0);  // Get the menu id parameter
                                // Check if this is a multi-lingual site
                                if (JLanguageMultilang::isEnabled()) {
                                    $lang = JFactory::getLanguage();
                                    $languages = JLanguageHelper::getLanguages();
                                    // loop through the lanuguages looking for the one active on the frontend currently
                                    foreach ($languages as $language) {
                                        // Check to see if this is the active frontend language
                                        if ($language->lang_code == $lang->getTag()) {
                                            $url =    $url . '&lang=' . $language->sef .( $itemid ? '&Itemid=' . $itemid : '&Itemid=' . $menuid );
                                            break;
                                        }
                                    }
                                } else {
                                    // code for non-multi-lingual site
                                        $url =    $url . ( $itemid ? '&Itemid=' . $itemid : '&Itemid=' . $menuid );
                                }
                                $app->redirect( JRoute::_( $url, false ), null, null, true, true );
                            }
                        }
                    }
           }

Does anyone know what the issue could be?

Thank you.
Reply all
Reply to author
Forward
0 new messages