working with Magento 2.4.4

I have customer groups General and B2B.

For B2B customer group I would like to display: "You are logged in in the B2B area" after customer logged in.

How could I possibly solve this?

Does anyone has an idea how I could visualize for customers in frontend that they are logged in in a specific B2B area?

1 Answer 1


You can just retrieve the current store

First create an observer that will check url

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="layout_load_before">
        <observer name="redirectcustomer_success" instance="Vendor\CheckUrl\Observer\CheckCustomer" />

Then check if the customer is logged in and on which store

 * @param Observer $observer
 * @throws NoSuchEntityException
public function execute(Observer $observer){
    //in case you want to filter the behaviour on different url or action
    $currentUrl = $this->_urlInterface->getCurrentUrl();
    $fullActionName = $this->request->getFullActionName();
    $currentStoreCode = $this->storeManager->getStore()->getCode();
    $isStorePro = $currentStoreCode == 'YOUR_PRO_STORE_CODE';

        if($this->_customerSession->isLoggedIn()) {
            //Do whatever you want there

This would be with an observer to adapt a specific backend treatment.

If you just want to add a sentence in frontend; then use a Helper with the same code and just call the helper in your template.

  • Thank you very much We will check this solution and let you know the result.
    – Ben
    Commented May 25, 2022 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.