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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cburschka’s picture

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

catch’s picture

chx’s picture

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

webchick’s picture

you will suddenly see things that you should not

Do 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?

chx’s picture

no but if you have links which are visible only to anonymous they will appear.

chx’s picture

Status: Active » Needs review
FileSize
6.99 KB

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

chx’s picture

I 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'.

Dries’s picture

Are 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. ;)

chx’s picture

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

chx’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.17 KB

OK, we like the global. Piece of cake, really. I will file the update glitch as a separate.

Dries’s picture

I like #10 better. I'll leave it in the queue for a bit; maybe people have thoughts and or suggestions for improvement.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

Murz’s picture

Status: Closed (fixed) » Active

I 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?

chx’s picture

Status: Active » Reviewed & tested by the community
FileSize
427 bytes

Trivial fix.

Gábor Hojtsy’s picture

Status: Reviewed & tested by the community » Fixed

Committed.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

alexanderpas’s picture

Version: 6.x-dev » 7.x-dev
Status: Closed (fixed) » Active
chx’s picture

Status: Active » Closed (fixed)

yes i saw but why are you reopening this?

ZhuRenTongKu’s picture

Issue summary: View changes

Just 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

/**
 * Add user/register link to test menu
 */

function test_update_7100() {
  $form_state = array(
      'values' => array(
          'menu_name'  => 'menu-test',
          'weight'     => 0,
          'link_title' => 'Register',
          'link_path'  => 'user/register',
          'mlid'       => 0,
          'customized' => 1,
      ),
  );

  // Save the item to database.
  menu_link_save($form_state['values']);
}