Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm trying to add a "register" link to my primary nav. However when I add a menu item with the path "user/register", I get a validation error stating: "The path 'user/register' is either invalid or you do not have access to it."
As a logged-in user, I do not have access to this path, but I still should be able to add it to the navigation to appear for anonymous users.
Comment | File | Size | Author |
---|---|---|---|
#15 | user_register_admin.patch | 427 bytes | chx |
#10 | menu_is_visible_for_admin.patch | 2.17 KB | chx |
#7 | menu_is_visible_for_admin.patch | 7.12 KB | chx |
#6 | menu_is_visible_for_admin.patch | 6.99 KB | chx |
Comments
Comment #1
cburschkaThree options I can think of:
1.) use a special case check (yuck)
2.) or make the menu administration ignore access (insecure with multiple site admins of various levels)
3.) make user/register stop using user access to hide itself (instead showing its own error message of "you're already registered").
Comment #2
catchRelated to: http://drupal.org/node/190867
Comment #3
chx CreditAttribution: chx commentedThis is one nice problem -- if you would be able to add, you won't see it as the menu overview page only shows whatever you have access to. If I fiddle with the callback (user_is_anonymous) then while editing the menu you will suddenly see things that you should not. Thus I need to fiddle with the way access check is run when menu module invokes it. Yuck.
Comment #4
webchickDo you mean things like node/%/edit, or..? Could we possibly handle this by checking for wildcard characters in the menu tree and outputting everything else?
Comment #5
chx CreditAttribution: chx commentedno but if you have links which are visible only to anonymous they will appear.
Comment #6
chx CreditAttribution: chx commentedWe can do this. Fairly little impact. As I looked for type flags, I found a flaw in menu update, noone dealt with expanded, I fixed that and I am way too sleepy to file a separate issue for that.
Comment #7
chx CreditAttribution: chx commentedI am not saying this is ideal, that's why there are no doxygen for this new param. If we agree on it, I will add doxygen. We just say "these menu elements are visible by admin' and then 'hey, admin here'.
Comment #8
Dries CreditAttribution: Dries commentedAre there other examples where this could be an issue or is user/register sort of a special case? I guess other links could have the same problem.
I don't think it makes sense to manually 'tag' menu paths that should be visisble by an admin. Am I wrong when I say that an admin should be able to see _all_ menu paths? As such, the property should be implicit instead of explicit? Am I missing something? Please enlighten me. ;)
Comment #9
chx CreditAttribution: chx commentedDrupal has no admin conception. Just because you can administer menus, you can't administer filters. This strict access checking is a problem for anonymous only pages. We have remarkably few of those: login, register and forgot password (which I forgot to tag). I do think it's a useful feature in d6 that as menu admin you can't see all sort of pages otherwise you could not see.
I can offer another solution: a global $menu_admin variable which the user_is_anonymous (and other interested parties in custom modules) can check.
Comment #10
chx CreditAttribution: chx commentedOK, we like the global. Piece of cake, really. I will file the update glitch as a separate.
Comment #11
Dries CreditAttribution: Dries commentedI like #10 better. I'll leave it in the queue for a bit; maybe people have thoughts and or suggestions for improvement.
Comment #12
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #13
(not verified) CreditAttribution: commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #14
MurzI have this problem again in Drupal RC1: when I try to add menu item with path "user/register" I have an error:
The path 'user/register' is either invalid or you do not have access to it.
I thing this is concerned with problems like http://drupal.org/node/118498. Does RC1 needs a newer patch?
Comment #15
chx CreditAttribution: chx commentedTrivial fix.
Comment #16
Gábor HojtsyCommitted.
Comment #17
(not verified) CreditAttribution: commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #18
alexanderpas CreditAttribution: alexanderpas commentedPlease read: #327230: user_is_anonymous() is ugly
Comment #19
chx CreditAttribution: chx commentedyes i saw but why are you reopening this?
Comment #20
ZhuRenTongKu CreditAttribution: ZhuRenTongKu commentedJust in case anyone comes across this, I've found that putting the menu link creation into an update hook works just fine
example test.install