I have a link which I've added to the Account Navigation in Magento2. It's called VIP Customer Info.
I would like to be able to hide or disable this link depending on weather the customer is logged in and belongs to the VIP customer group.
Any suggestions on how this could be possible? I have tried the method below but it didn't work :(
Maybe I need to manage it from template file?
I thought I could achieve this by using a method from custom block in view/frontend/layout/customer_account.xml
<referenceBlock name="customer_account_navigation">
<block class="Holy\Vip\Block\Html\Link\Vip" name="customer-account-navigation-vip-info-link">
<action method="isVipCustomer">
<arguments>
<argument name="label" xsi:type="string" translate="true">VIP Customer Info</argument>
<argument name="path" xsi:type="string">vip/customer/info</argument>
</arguments>
</action>
</block>
</referenceBlock>
But this didn't work, it just stopped the link from being rendered at all.
This is my block class:
<?php
namespace Holy\Vip\Block\Html\Link;
class Vip extends \Magento\Framework\View\Element\Html\Link\Current
{
public function isVipCustomer()
{
return true;
}
}
Unfortunately, this does not work. It just shows a empty space with a link to the homepage no matter what the return value:
Since private content is specific to individual users, it’s reasonable to handle it on the client (i.e., web browser).