1

I have these roles:

  • anonymous user,
  • authenticated user,
  • administrator,
  • members,
  • partners.

In URL Aliases I changed at USER PATHS with this: [user:roles:join-path]/[user:name]

I created 2 views for user: first for members role and second for partners role (the views contain userpicture and username). The link for these users in both roles are :

  • www.example.com/authenticated-user/members/username
  • www.example.com/authenticated-user/partner/username

I know that authenticated user role is default for authenticated users, but it is possible to remove from USER PATH: from „www.example.com/authenticated-user/members/username” to „www.example.com/members/username”?

Thank you.

1

You can implement hook_pathauto_alias_alter(), which is invoked from pathauto_create_alias(). The function passes the pattern used from the Pathauto module before the tokens are replaced in $context['pattern']. You probably want to check the pattern contains "[user:roles:join-path]" to avoid "authenticated-user" is removed where the pattern explicitly uses "authenticated-user".

The alternatives would be:

  • Implement hook_tokens_alter() to alter the output of that token, but that would change it in any place the token is used, not only in alias created from the Pathauto module

  • Implement hook_tokens(), and hook_token_info() to implement a token similar to [user:roles] but that doesn't include the string for the authenticated user role

Notice that it is the Pathauto module that handles the :join-path part of the token, in pathauto_tokens().

0

If Pathauto doesn't let you to specify a single role, I think you should create a little module that makes the same thing of pathauto but add only your favorite roles.

Pathauto has also some api and hooks, try to search there.

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.