Categories
Magento

Magento – Get Logged In Customer’s Group ID

[php]
<?php
/* Check if customer is logged in */
$isLoggedIn = Mage::getSingleton(‘customer/session’)->isLoggedIn();
/* If customer is logged in */
if($isLoggedIn) :
/* Get the logged in customer’s group ID */
$customerGroupId = Mage::getSingleton(‘customer/session’)->getCustomerGroupId();
/* Check if the logged in customer’s group ID matches with the ID you are after */
/* Customer group IDs are listed against each group under Admin > Customers > Customer Groups */
if($customerGroupId == 3) :
echo ‘Welcome Retailer’;
endif;
endif;
?>
[/php]
You can also write static blocks or custom variables to contain group specific information. You can name the static block identifier based on the $customerGroupId and retrieve it on the front end.

3 replies on “Magento – Get Logged In Customer’s Group ID”

Comments are closed.