I want to show Login link in the Menu navigation, only for guest User.
clinical_trial.login:
title: Login
description: 'Login'
parent: main
menu_name: main
route_name: user.login
This is my Custom Menu links code.
What to add?
I want to show Login link in the Menu navigation, only for guest User.
clinical_trial.login:
title: Login
description: 'Login'
parent: main
menu_name: main
route_name: user.login
This is my Custom Menu links code.
What to add?
If you are creating a menu link from a custom module, you can check this
https://www.drupal.org/docs/8/api/routing-system/structure-of-routes
Quoting the documentation:
requirements (required): Determines what must be met in order to grant access to the route.
_role: A specific Drupal role, eg. 'anonymous'.
Alternatively you can use this module: https://www.drupal.org/project/menu_item_visibility "It exposes configurable and extendable visibility settings for menu links."