Thank you Guys.
below is the observer function that worked for me
public function setRedirectOnLogin(){
$session = Mage::getSingleton('customer/session');
if (strpos(Mage::helper('core/http')->getHttpReferer(), 'checkout') === false)
$session->setAfterAuthUrl(Mage::getBaseUrl());
else
$session->setAfterAuthUrl(Mage::helper('core/http')->getHttpReferer());
$session->setBeforeAuthUrl('');
}
As all the comments stated before, its not out of the box.
Here are some hints on where/what you may need to adjust:
Mage_Admin_Model_User
public function getStartupPageUrl()
{
$startupPage = Mage::getStoreConfig(self::XML_PATH_STARTUP_PAGE);
$aclResource = 'admin/' . $startupPage;
if (Mage::getSingleton('admin/session')->isAllowed($aclResource)) {
$nodePath = 'menu/' . join('/children/', explode('/', $startupPage)) . '/action';
$url = (string)Mage::getSingleton('admin/config')->getAdminhtmlConfig()->getNode($nodePath);
if ($url) {
return $url;
}
}
return $this->findFirstAvailableMenu();
}
I have never tried it but this seems to be the method called from
Mage_Adminhtml_IndexController
and there is the IndexAction that calls the above function.
Since this is the admin, doing a rewrite of the Model will probably be easier.
/**
* Admin area entry point
* Always redirects to the startup page url
*/
public function indexAction()
{
$session = Mage::getSingleton('admin/session');
$url = $session->getUser()->getStartupPageUrl();
if ($session->isFirstPageAfterLogin()) {
// retain the "first page after login" value in session (before redirect)
$session->setIsFirstPageAfterLogin(true);
}
$this->_redirect($url);
}
So, modifying getStartupPageUrl() to have your URL seems very likely the best place to try this.
This is all theoretical, I have not tried it yet, but if you need a sample module, I can certainly run through this and provide it.
If every admin user will end up on the same page, its pretty easy to do, if there is some dynamic elements, it will be a bit harder to facilitate.
Good Luck!
Best Answer
Short answer:
The redirect is done to the page selected in
System > Configuration > Admin > Startup Page
.If you already defined a menu node for your admin page, you should be able to select it form the dropdown.
Further information:
The dropdown consists of system config values form the source model
adminhtml/system_config_source_admin_page
built inapp/code/core/Mage/Adminhtml/Model/System/Config/Source/Admin/Page.php
This iterates through all
<menu>
nodes from the admin config entries.The corresponding XML config node is
admin/startup/page
where the corresponding URL for the redirect is retreived inMage_Admin_Model_User
.The actual redirect happens in
Mage_Adminhtml_IndexController
: