How to print username into url after user logs in? Currently, I am developing a site where I need to add the username to the URL after users log in. I am using the Login destinations module. Usually, users aren't redirected, but they stay on the page they were before logging in, with few exceptions. This unfortunately has to stay, so I cannot redirect them to users/username.

I need to add the username to the URL after users log in. For example, not logged-in users will be at content/main-article; logged-in users will be at content/main-article?username.

I tried that with the Menu tokens module, but the tokens aren't replaced. A relative URL like node/1 becomes node/1/%5Buser%3Aname%5D.

If you ask why, it is for Piwik to easily recognize logged-in users.
I am not sure how and where you append the username, but I assume that you try something like this:

$url = $current_url . '?user=name';


Instead you should try something like this:

$url = url($current_url, array('query' =&gt; array('user' =&gt; 'name')));


This will produce this URL: current_url?user=name

Another thing: You have %5B and 3%A in your URL. I am not sure, but you want to have your URL look like this: url[user:name]. Queries in URLs should rather look like I did that and how Drupal's query options creates them: url?user=name

If that does not solve it, you could post some code ;)

Cheers,
j