1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Member profile vanity URLs / access member profiles via user name only

Discussion in 'XenForo Suggestions' started by g0rn, Oct 1, 2010.

  1. g0rn

    g0rn Well-Known Member

    In vBulletin, you can access user profile by either visiting /member.php?u=123456 or /member.php?username=john
    As far as I can see, in Xenforo you have to know user id, not only username (you can use either /members/john.123456/ or /members/123456/ but not /members/john/).
    So, I would like to have a possibility to access profile by simply substituting username to the url.
    Infopro, Goodfella, empire and 11 others like this.
  2. Sejper

    Sejper Active Member

    Verry good suggestion wich I would like to be implemented also.
  3. Shamil

    Shamil Well-Known Member

  4. dutchbb

    dutchbb Well-Known Member

  5. Shamil

    Shamil Well-Known Member

    True, however, XenForo uses user IDs to get the user data.
  6. Paul M

    Paul M Well-Known Member

    Since in both your cases, MySQL knows it only needs to examine 1 row, the difference between them is for all intents and purposes non existant. :)
  7. Shamil

    Shamil Well-Known Member

    Well yes, it would be a bit more extreme in a forum usertable scenario. Also, if someone has a non-standard character in their username, and they've made it a long-ish username. I'm not going to want to spend time trying to get their profile.
  8. Mike

    Mike XenForo Developer Staff Member

    That is generally true, but there is still an ambiguity in the URL without the ID. Is that user "Bob K" or "Bob-K"? There are characters that can be used in names that aren't allowed in URL forms like that (/ being the obvious one).
  9. dutchbb

    dutchbb Well-Known Member

    Yes indeed, we needed to enable a limitation on usernames at registration and make them match a regular expression. So spaces are allowed, hyphens are not.

    So if XF allows the option to not use the id in profiles, then it would require an extra setting in the UCP to prevent the use of these special characters that can cause problems. I think it's a small offer to make for a better URL though.
    Veer likes this.
  10. Shadab

    Shadab Well-Known Member

    An option to limit usernames by a regular expression is already present, btw. :)
  11. feldon30

    feldon30 Well-Known Member

    I can search for posts by a username, I don't have to enter a userid. The point of a relational database is that you only use userid when referring to a user, just like you only store the threadid when referring to a thread, but it's trivially easy to do a lookup to match up an ID with the actual information.

    This doesn't have to be a perfect scenario. I can use a URL to lookup a user, but if the username contains characters that are impossible in a URL, then this method cannot be used to look up that user. And with the availability of special characters (%20 anyone?), it's possible to specify almost any character in a URL. The fact that username=______ won't work for every forum, or every user is not an ironclad justification not to offer that feature.
  12. Shamil

    Shamil Well-Known Member

    Yes - but how many people constantly visit the user's profile page by URL?
  13. feldon30

    feldon30 Well-Known Member

    Since the feature is not available, I'm guessing very few. ;)

    Just for sake of argument, the User table is not even in the top 5 or top 10 tables in size in vBulletin, and I'm guessing this is also applicable to XenForo, depending on whether the database has been normalized.
  14. Shamil

    Shamil Well-Known Member

    Very true. Would people still try to find the user by URL? The majority of users may user the memberlist, or whatever, but the last thing they'll do is enter the username in a URL to get to the user (if the function was available).
  15. dutchbb

    dutchbb Well-Known Member

    I'm not sure I understand your reply correctly, but I want to state that I don't think special characters should be allowed in usernames. A-Z 0-9 and spaces (which are replaced by a hyphen) should be enough and keeps things clean.

    With a vbseo enabled vB forum, when you type for example:

    http://forum.domain.com/members/groundhog day

    it automatically redirects to:


    It'd be nice to see a similar behavior in XF.
  16. James

    James Well-Known Member

    0xym0r0n likes this.
  17. Wulfspider

    Wulfspider Active Member

    I'd like to see this as well. I haven't look over the code yet to see if I want to get into it or not, but a way of remapping it so that either are still valid would be wonderful.
  18. James

    James Well-Known Member

    In the event of a username change, you won't be able to access that user's profile via their username any more (obviously).
    M@rc likes this.
  19. Fuhrmann

    Fuhrmann Well-Known Member

  20. Fuhrmann

    Fuhrmann Well-Known Member

    So I made some tests and actually this can be easy implemented.

    In the XenForo_Route_Prefix_Members change the:

    $action $router->resolveActionWithIntegerParam($routePath$request'user_id');

    $action $router->resolveActionWithIntegerOrStringParam($routePath$request'user_id''username');

    Works here!
    seriosbrad and 0xym0r0n like this.

Share This Page