This is about the pattern for user account page paths.

In my site I want to have different urls for the various user roles, e.g. teacher/user-name and student/user-name.

I cannot use [user:roles:first], since that would yield 'authenticated-user', which in my case needs to be on top in the roles list as it is the least permissive role. For similar reasons [user:roles:last] would not work for me either: what I need is the second role in line (the first one listed after authenticated-user), even if the user has other roles with more permissions.

So to achieve this I tried to use the following pattern:
The user-name part works, but not the role part: it is simply not there.
If I test with [user:roles:keys:value:1] I can see this gives me the correct key of the role, but the role-name itself does not appear when I use [user:roles:value:1].

I'm not sure if this is a pathauto issue or a token issue.
Any help would be much appreciated.



ben.kyriakou’s picture

Issue summary: View changes

Hi Jos. Unfortunately you're running into an issue with how Token deals with roles (and similar tokens). The argument in the token doesn't refer to the array order, but to the role id - your token is asking for the role with rid 1 (if the user has that role). Depending on your setup, there is a slightly grotty solution to this. If you have a subset of roles you want to use for aliasing, and you know that the user will only have one of them at a time, you could set a pattern like this:


Assuming users can have either the role with rid 3 or rid 4, but not both, it will generate the kind of path you're after since the other value will be empty and the extra slashes will be stripped from the final alias.

If this doesn't solve your problem, I'd suggest filing this against the Token issue queue.