4

I am trying to set up username as a main path to the user profiles in Drupal 7; for example, I would like to have mypage.com/someusername as path alias for the profile of the user that uses "someusername" as username.

I am using the Profile 2 module as well. I tried everything, but I cannot achieve this.

7

If you use the Pathauto module, you can set an automatic alias for the user profiles using a token that is replaced with the username. In Pathauto for Drupal 7, the default pattern for user paths is /users/[user:name], which is the pattern I would suggest to use to avoid conflict with path defined from other module. As you don't control the username chosen from a user, it could happen the username is admin, which conflict with the path used from system.module for its own menu callback.

If you want to use a different token, the list of available tokens is available right after the text field used for the pattern to use.

screenshot

What I reported is still valid for Drupal 6; the difference is that the token for the username is [user].

1

There is the Menu token module for defining paths like 'user/[user:uid]'.

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

Tokens are provided by Token module. Menu Token allows to use both global tokens and entity one: node, user, term. Entity tokens have several methods of substitution: from context, random and user defined.

  • In this case, it doesn't help, as the profile path is already defined from a module. – kiamlaluno Aug 1 '12 at 14:24
0

Just came across this issue and in case anyone reading this didn't get much enlightenment, I'll light up a bit more.

By default, drupal use "user/{user_id}" for the path to your Profile page. And on your path page above it could written "users/[user:name]" to go to some page like www.example.com/not-my-real-name-but-username-use-for-login

So to link to your Profile page,

  1. aside from setting the Path like kiamlaluno described above...

  2. remember to Delete all your user aliases on "Delete aliases" tab and rebuild them using the new pattern you entered above from "Bulk update" tab.

Hope that helps. Saved me few hours.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.