Redirect after User Edit their address/bill to information

Started by itsnow, June 09, 2013, 21:46:25 PM

Previous topic - Next topic

itsnow

Hello,
I want to redirect the user to a specific page after they press 'Save' or 'Cancel' button on the Edit Address/Bill to/Add new address pages.
Right now when 'Cancel' is pressed, user gets redirected to home page of Virtuemart 'component/virtuemart/', and I'm not using such page at my site, so I would like to change that. Or if the user presses 'Save', he gets redirected to 'index.php?option=com_virtuemart&view=user&layout=edit' page, and I don't want to make this page available to the user, so I use only the page 'index.php?option=com_virtuemart&view=user&layout=editaddress' for editing address/bill to information.
I tried changing the redirect address on line 149 of file: "\components\com_virtuemart\controllers\user.php", but then after pressing the 'Save' button, just blank screen appears, even when a new user is getting registered, only blank page shows on pressing the 'Register' button, when I make this change in user.php file.

If anyone has an idea how this can be changed, I would be very thankful?

I use Joomla! 2.5.11 and VirtueMart 2.0.20b

Thanks.

itsnow

Hello,

I found the solution for redirecting to the desired page.
So if someone has a similar issue, here is the way to do it:

For redirecting on pressing  "Cancel" button:
You need to override the view "com_virtuemart\user\edit_address.php" in your template, the line is 187. You need to change it from:

<button class="default" type="reset"
       onclick="window.location.href='<?php echo JRoute::_ ('index.php?option=com_virtuemart&view=' . $rview); ?>'">
       <?php echo JText::_ ('COM_VIRTUEMART_CANCEL'); ?>
</button>
      
To:

<button class="default" type="reset"
       onclick="window.location.href='<?php echo JRoute::_ (JURI::root() . 'home'); ?>'"><?php echo JText::_ ('COM_VIRTUEMART_CANCEL'); ?></button>
       <?php echo JText::_ ('COM_VIRTUEMART_CANCEL'); ?>
</button>

In window.location.href='<?php echo JRoute::_ (JURI::root() . 'home'); ?> you place the desired url address.

For redirecting on pressing  "Save" button:
You need to modify the file "\components\com_virtuemart\controllers\user.php". The function 'saveUser()' on line 145 and function saveAddressST() on line 153, the code to modify is "$this->setRedirect( JRoute::_('index.php?option=com_virtuemart&view=user&layout='.$layout), $msg );", the modification should be something like this:
$this->setRedirect( JRoute::_(JURI::root() . 'home'), $msg );

It seems like I had been trying to redirect to address that hadn't been valid, because of not using the "JURI::root() " function.

Thanks to all for taking time to read my question.
Greetings.

creyl