The MU forums have moved to WordPress.org

How can I allow spaces in usernames? (17 posts)

  1. LikeTheRazor
    Member
    Posted 17 years ago #

    Hello, I was wondering if anyone knows a way to allow new users to register usernames with spaces. Thanks.

  2. lunabyte
    Member
    Posted 17 years ago #

    No. It isn't possible.

    Whether the install uses subdomains or subdirectories, the username becomes part of the url. Spaces create malformed url's.

  3. LikeTheRazor
    Member
    Posted 17 years ago #

    Hmm. Is it possible to do something like this:

    User names with spaces like: John Doe

    and the blog url: website.com/blogs/john-doe/

  4. lunabyte
    Member
    Posted 17 years ago #

    What's wrong with using the displayed name?

    That's what it's for.

  5. LikeTheRazor
    Member
    Posted 17 years ago #

    What I don't like about the display name is that people can have identical display names.

    It shouldn't be terribly hard to hack it so that you can use spaces in user names right? I'm not exactly a PHP expert so that's why I'm asking here if anyone knows how to do it.

  6. LikeTheRazor
    Member
    Posted 17 years ago #

    I think I found where it checks for spaces in the code. This is from the function wpmu_validate_user_signup in wpmu-functions.php:

    preg_match( "/[a-zA-Z0-9]+/", $user_name, $maybe );

    if( $user_name != $maybe[0] ) {
    $errors->add('user_name', __("Only letters and numbers allowed"));

    Anyone know how to modify this to allow spaces?

  7. drmike
    Member
    Posted 17 years ago #

    Maybe waiting for someone to respond may help. :)

  8. lunabyte
    Member
    Posted 17 years ago #

    You're not listening.

    If you allow spaces in the username, aka login, you're going to break your site.

    I'm going to guess that you're looking for some type of display option, so use their profile settings for last name, first name, or whatever.

    One more time to clarify:

    YOU CAN NOT ALLOW SPACES IN THE USER NAME. IT BREAKS URL'S, AND WILL BREAK YOUR SITE.

    Technically, yes you can modify the code to allow it. The end result is it's going to break all your links.

    So, like it or not, that's the way it is.

  9. LikeTheRazor
    Member
    Posted 17 years ago #

    What does it break about the URLs? I have it working now so I can register usernames with spaces.

  10. drmike
    Member
    Posted 17 years ago #

    And the URLs work? Must be translating the spaces to

    %20
    's or something.

  11. lunabyte
    Member
    Posted 17 years ago #

    Most likely, since it does that with malformed url's.

    You go to homedepot.com, not home depot.com. Plus it generates additional strain on the server, to say the least.

  12. meerblickzimmer
    Member
    Posted 15 years ago #

    @LikeTheRazor: how did you solve the problem with spaces? can you explain it - i need also a solution.

    Thanks a lot! M

  13. lunabyte
    Member
    Posted 15 years ago #

    User names (logins) CAN NOT contain spaces.

    That's what the displayed name field in the profile is for.

  14. jmasson
    Member
    Posted 14 years ago #

    Interested to hear if anyone has proceeded with allowing spaces in the usernames and whether they faced any issues?

    I am building up a Wordpress MU Install using the LDAP Plugin (http://wpmuldap.frozenpc.net) and am hitting the problem that the user names in Active Directory all have spaces, but when Wordpress saves the username it removes the space - which means the username doesn't match AD, and you can't log in...

    I am thinking of either allowing spaces in the username, or modifying the login process to strip the space from the username (firstname lastname) to authenticate against Wordpress, but retain it when connecting to LDAP... Weighing up which is the best option, and what else can be done...

    Don't really want to hack the code as it will need repeating for upgrades though...

    Has anyone else faced this issue?

  15. kgraeme
    Member
    Posted 14 years ago #

    We use LDAP but we use the person's email account instead of their full name. Email accounts can't have spaces either (though they commonly do include a period ".").

    We also don't generate a blog based on the user's name though. So email accounts like "firstname.lastname", which would be invalid in Wordpress and certainly bad for URLs, work for login only.

    I will say though, that anyone that wants to deviate from the standard user account model in WPMU, even if it's just implementing a plugin like LDAP or OpenID, needs to be very adept at writing their own code customizations and comfortable at solving their own problems because once you deviate from the standard, all bets are off for help.

  16. tdjcbe
    Member
    Posted 14 years ago #

    all bets are off for help

    I think that's because most of us aren't in such a situation or we're basing the user management around wpmu instead of using wpmu as a subinstall.

    I know the fanciest I've ever got was merging it with a vBulletin install and that's been beat to death. Luckily. :)

    And I thought the dot in the username worked. It used to...

  17. kgraeme
    Member
    Posted 14 years ago #

    I think that's because most of us aren't in such a situation or we're basing the user management around wpmu instead of using wpmu as a subinstall.

    Yep. Not a criticism of WPMU or the community. It's just a given that when someone starts blazing their own trail that there aren't going to be lots of signposts to tell them where they're going.

    With that said, the LDAP plugin worked pretty well when we started with it and we only had to modify it a bit. I think some of our changes even got incorporated into the project.

About this Topic

  • Started 17 years ago by LikeTheRazor
  • Latest reply from kgraeme