I have a number of menus that point to the users registration component. Depending on where the user registers I redirect them accordingly with a custom plugin.
public function onUserAfterSave($user, $isnew, $success, $msg)
{
//get the active menu item id so we can compare what plan we are on
$menu = $app->getMenu();
$active = $menu->getActive();
$activeId = $active->id;
//compare active page (i.e. what menu item are we on) with the parameter set in the plugin
//if it matches redirect accordingly - fallback is to always redirect to free plan
if ($activeId == $this->params->get('free-reg-menu'))
{
//redirect required to go to main page
JFactory::getApplication()->redirect(JRoute::_('page1'));
}
else if ($activeId == $this->params->get('bv-reg-menu'))
{
//redirect to step 2 of main plan payment processing
JFactory::getApplication()->redirect(JRoute::_('page2'));
}
else if ($activeId == $this->params->get('prem-reg-menu'))
{
//redirect to step 2 of value plan payment processing
JFactory::getApplication()->redirect(JRoute::_('page3'));
}
else
{
//other stuff
}
}
Depending on what menus were assigned in this plugin I redirect the user to a specific page. This all works quite well.
My problem is when registration fails (ie. duplicate username, wrong matching passwords etc.) the page does a refresh due to the server side validation. This refresh brings the page away from the original link. It seem to redirect to the first registration menu page I created.
For example: I'm on a registration page and I enter wrong credentials then the page refreshes to a completely different page. Any ideas? I guess an extension for AJAX registration might address this but I'd like to avoid that for now.