Static Block – Showing Static Block Only to Specific Customer Group

customer-groupstatic-block

I have a webshop were I have to hide away the login and create user form, because I only want customers with a specific link to be able to register. When they have registered they will be able to see a category that only they have a link for.
What I want to do is create a static block that contains links to this category, customers dashboard etc. that only logged in users/or users in a specific customer can see.
How can i achieve this?

Best Answer

Use Mage::getSingleton('customer/session')->isLoggedIn() before your block as a conditional and you have scenario 1 fixed.

Also you can use Mage::getSingleton('customer/session')->getCustomerGroupId() to get the Customer group Id as another conditional before echoing your block. See how to echo a block here.

Complete code:

<?php if (Mage::getSingleton('customer/session')->isLoggedIn() && Mage::getSingleton('customer/session')->getCustomerGroupId() == "something") :?>
    <?php echo $this->getChildHtml('sample_links') ?>
<?php endif;?>

Remember to define your block in your XML file.

Related Topic