Hiding menu item depending on specific access I work on a D8 (8.6)
I want to hide some item on my menu depending on route param onto this link.

When I try to access the route I get a 403 error and works as expected but the the link inside the menu is still displayed.

I create a custom Accessinterface which return an AccessResult::allowed() or denied() depending on my rules.

Is there a core solution to prevent the link to be displayed on the main menu or I have to handle it in JS ?

My CustomAccessCheck : 

class CustomAccessCheck implements AccessInterface
{

  public function access(AccountInterface $account)
  {
    $isAuthenticated = $account-&gt;isAuthenticated();

    try {
      $currentGroup = TestEntity::getInstance()-&gt;currentGroup;
    } catch (InvalidPluginDefinitionException $e) {
      return AccessResult::forbidden();
    }
    if ( $isAuthenticated &amp;&amp;
      ( !empty($currentGroup["id"]) &amp;&amp; isset($currentGroup["IsActive"]) &amp;&amp; $currentGroup["IsActive"])
    ) {
      return AccessResult::allowed();
    }
    return AccessResult::forbidden();
  }
}


I configure services and routing.yml in order to run this AccessChecker.
The custom menu contain some menu items which target the route configured.

My problem is even if the user don't have access to the route the menu item is displayed.

Thanks for help
Nico
I found by myself my mistake.

The menu items are always shown for super user.

The menu items are hidden/shown correctly for others users.