Closed (fixed)
Project:
Drupal core
Version:
8.1.x-dev
Component:
menu system
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Feb 2011 at 15:05 UTC
Updated:
18 Jun 2020 at 17:42 UTC
Jump to comment: Most recent
Comments
Comment #1
montesq commentedAccording to http://api.drupal.org :
If the value is FALSE, the user can't access this menu so it doesn't need to display this link...
Comment #2
snufkin commentedSo how would you position a menu item that you created in a custom module that is visible only under certain conditions (say user is not authenticated then show the login link, if user is not authenticated then dont)? The menu item should be visible on the admin UI.
Comment #3
montesq commentedIf the access callback is set to FALSE, the menu would be *never* available.
In fact, access callback must be set to the function that will return TRUE if the user is able to access to this menu, FALSE if not.
You can use access arguments if needed.
Almost every module implements hook_menu, for example, you can look at the user.module to have some examples...
Comment #4
snufkin commentedI am talking about the case when the access callback returns FALSE to hide the element...
An example: your module implements a logout and a login link, programmatically. Obviously you dont want to show the logout link to an anonymous user, and the login to an authenticated, so you use an access callback function that checks the login status and returns true/false accordingly.
Now assume that you would fancy placing these items somewhere in the menu. You cant, because you are logged in, so the admin interface will not show the logout link, since the access callback returned false. So you must give permission to the anonymous user to configure menus. And all this assumes that the access callback looks at a simple thing, like authentication status.
I hope I made my request a bit clearer.
For the records: chx explained to me that the main reason why these issues are closed is because they would lead to information disclosure about links that the person accessing the admin ui should not have access. If aforementioned feature is needed implement the access callback so that your admin user can get a TRUE return regardless of underlying conditions.
Comment #5
montesq commentedOk, well understood. I've tried to rephrase the issue title. Does it make sense for you?
However, currently a user with administer menu is not able to create a menu linked to an invalid or out of reach page. So it's quite logical that he/she can view it in the item menu list...
Comment #6
dave reidRelated: #916388: Convert menu links into entities
Comment #7
jhedstromComment #8
dawehnerWe have a dedicated permission for that now:
link to any pageso they are able to see the list. I think this feature request is solved by that now.Comment #10
xjm