I am trying to redirect a specific customer group to a single CMS page. Not just after logging in, but whenever they try to go to any page, it will just redirect them to the CMS page.
The only file I figured I could add code is in header.phtml
.
$customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
if($customerGroupId == 5){
$redirect_url = Mage::getUrl('uhoh');
Mage::app()->getFrontController()->getResponse()->setRedirect($redirect_url)->sendResponse();
}
This is what I currently have. It's purpose works, but it's not exactly what I want. The purpose is for a "blocked" customer group. This code sends the user into an endless redirect, but I want to have information displayed on the CMS page, which means no page is useless despite actually blocking the group from using the site.
Is there an issue with the code? Or would it be easier and more effective to create a module for this?
$currentUrl = Mage::helper('core/url')->getCurrentUrl();
if(!$currentUrl == $url) { //redirect}
but it failed. However,if($currentUrl == $url) {} else { // redirect }
worked perfectly. Thanks so much!if($currentUrl != $url) { //redirect}
but glad you got it to work!!($currentUrl == $url)
could have worked.