5

Ok, I must be missing something obvious, but I'm having trouble adding a link to user/%/edit to the main menu. In the Menu UI, I clicked "add link," set the title to "Account settings," and then was at a loss about what to put for the path. I know how to generate a link to the account edit page using views, which is what I've always done before, but this time I actually need to add the link to the "Main Menu."

4 Answers 4

0

In Drupal 8,9,10 etc. you can do this by providing a custom route to point to /user/edit for example and have this route call a controller to perform a simple redirect. You can then simply link to /user/edit from anywhere you want and the redirect will bring the user to their correct /user/%/edit form.

The User Current Paths module does exactly that. Use this module or have a look a their approach, which can be extended easily to provide more complex dynamic redirects as well.

11

Try this module menu_token , it allows to use tokens in menu

Menu Token module provides tokens, that could be used in title or in path of menu items (links). For example, if you create a menu item with path: "user/[current-user:uid]", the url will be changed "on fly" to: "user/1" (assuming you are user 1).

5

You can't use % as a wildcard when adding a menu item like that.

The me aliases module can help you do it.

You install that module and then you can add a menu item to user/me/edit and it will go to the currently logged in user's edit page.

3
  • The module smile mentions is a good option too.
    – rooby
    Apr 30, 2013 at 12:15
  • The 'me' aliases module changed all of my user admin links so I can't edit user tabs anymore so I won't recommend it.
    – Druvision
    Jun 11, 2013 at 13:12
  • It's a valid solution that works for me. I don't see why it is worth a down vote as it is not a wrong answer. But whatever.
    – rooby
    Jun 12, 2013 at 7:24
0

Create a node with input format filter set as PHP code and copy/paste the following code:

<?php
drupal_goto('user/'.$GLOBALS['user']->uid.'/edit');
?>

Under menu settings, create a menu link and add it to a menu.

https://drupal.org/comment/4098302#comment-4098302

1
  • 1
    Not an elegant solution, but would probably work.
    – Mołot
    Nov 21, 2013 at 8:21

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.