Redirect User To Login If User Is Not Logged In
<?php
$redirect_url = Mage::getUrl('customer/account/login/');
$current_url = Mage::helper('core/url')->getCurrentUrl();
if((!$this->helper('customer')->isLoggedIn()) && ($current_url != $redirect_url)){
Mage::app()->getFrontController()->getResponse()->setRedirect($redirect_url);
}
?>
Or a login Link To see Product details for non-logged in user:
<?php
if(!Mage::helper('customer')->isLoggedIn()) {
Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl()); ?>
<p>Please <a href="<?php echo Mage::getUrl('customer/account/login'); ?>" >Login </a>to view the product Details.</p><?php
}
else{
//Your product details here:
}
?>
1 Comment
JM · April 19, 2017 at 8:35 am
Hi can I ask a question, how to restricts specific CMS page from accessing if the customer is not logged in? This is for Magento 2.
Please help.