1

I currently use a mixture of Freemember & User to create my customised profile/account pages.

The urls for these types of pages are things like member/profile/{member_id}/favourites or member/profile/{member_id}/bookmarks

Where segment 3 is always the member ID.

I was wondering if its possible to change segment 3 to use the members username rather than the member ID?

It will make for nicer more personalised urls, but I'm not sure if there's a downside or if it even would work?

| improve this question | | | | |
  • Have you checked the User and Freemember docs to see whether a username parameter is available for the tags that you're using? It looks like username is a valid freemember parameter. – Dom Stubbs Feb 26 '13 at 15:38
  • Hmm, just had a check and it appears that username is a valid parameter in Solspace's Favourites module as well (I need this to work). So its looking like its possible. Just wanted to make sure there wasn't any obvious downsides to using the username in the URL. – shorn Feb 26 '13 at 16:32
  • I suppose you might run into issues if people are using non-alphanumeric characters, I'm not sure how strict EE is about the chars used in usernames. If it is fairly relaxed then you might need to look into URL encoding to avoid issues. – Dom Stubbs Feb 26 '13 at 16:57
2

Yes, you can use the username in the URL and display member profile data based on this username. See User's documentation on the username="" parameter in {exp:user:stats} for more details. From the documentation:

username="some_username"

This parameter allows you to show the specified members' stats. A variable like {segment_3} can also be used to pull a username from the URL.

The only caveat is when the username contains characters that EE or your server does not allow. Check your EE/Server settings if you encounter disallowed character-type errors.

Alternatively, you could make your registration/profile edit forms in a way that prevents the user of anything but alphanumerical characters, for example. A javascript/jQuery validation script could be used for that purpose.

| improve this answer | | | | |

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.