0

I have two sets of users, faculty and staff, with corresponding Profile2 profiles.

I can't figure out how to get different paths for users dependent on roles, e.g, staff/userid or faculty/userid.

I've been trying with both Rules and Pathauto. Seems like it should be simple but can't get work it out.

  • This should be doable by implementing hook_pathauto_alias_alter in a module. – user49 Sep 8 '13 at 7:00
  • Thanks, I'll probably try this approach. Was hoping it could be done through UI. – paulkeyes Sep 8 '13 at 20:52
  • Perhaps it's doable but I do not readily know how and it's always easier (at least for me) to write a small module than spend hours with Rules trying to piece such a thing together. – user49 Sep 9 '13 at 4:12
  • Another approach would be to use Page Manager (part of ctools). – Darvanen Nov 18 '14 at 5:17
0

Since I'm using profile2 (actually still learning about it, and about Drupal), I thought I'd have a go at this. One way would be to create a hidden field on the useraccount page, and populate that field with Rules during registration, e.g. for someone with staff role, give it as value "staff", and for a faculty role, give value "faculty". Then with Pathauto module, define a pattern for User Paths. It would look something like this [user:XXXXX]/[user:uid], where XXXXX is the name of the hidden field you created, prefixed with "field".

Hope that helps.

| improve this answer | |
  • That seems like it could work. I solved this in a similar way, using tokens in URL Alias config (admin/config/search/path/patterns). Rewrote path as: 'people/[user:profile-faculty][user:profile-staff]/[user:name-raw]'. Your tokens would obviously be different, depending on what fields you're calling. May be sub-optimal, but no user will be both faculty AND staff, so it works well enough. – paulkeyes Feb 5 '14 at 0:11
  • 1
    Keep in mind a user can add a value to a hidden element, so don't rely on that method for sensitive operations. – David Thomas Aug 25 '15 at 2:01

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.