I want to show Login link in the Menu navigation, only for guest User.

  title: Login
  description: 'Login'
  parent: main
  menu_name: main
  route_name: user.login

This is my Custom Menu links code.

What to add?


1 Answer 1


If you are creating a menu link from a custom module, you can check this


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."

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.