Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

View Category only if logged in
Sr. Member
Total Posts:  126
Joined:  2007-12-27

My client needs to disable the viewing of all products in a specific category unless the user is logged in. There is a plug-in out there that completely disables the category, but that also means removing it from the navigation, and not telling the user they can’t see the contents because they are not logged in. I just wanted to share what I did if others are looking for a similar solution. It’s a down and dirty solution, but it works…


<?php $disallowCategories 
= array(14); ?>
if(in_array($this->getCurrentCategory()->getId(), $disallowCategories) and Mage::getSingleton'customer/session' )->isLoggedIn() == 0): ?>

<div class="category-description">
p>Sorryyou need to be logged in to view <?php echo $this->getCurrentCategory()->getName(); ?>.</p>
p><a href="/catalog/customer/account/login">Login or create an account</a></p>

<?php else: ?>

... rest of file's code...

<?php endif; ?>

Note that this will not stop the user from directly accessing the products if they know the URL, but in my client’s case, it isn’t a big deal if the user does this.

Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top