usernames with spaces should not be allowed

on the registration page for the membership site plugin, a user is allowed to enter a username with a space in it. The registration will go through, but wordpress in the background will convert the spaces to a dash. The user will have no idea that wordpress added the dash. I think that the registration form should reject a space in the username, and tell them in the returned error that they can use a dash or underscore if they wish. Yes the user receives an e-mail with there username and password, but they are not going to read that, and if I was unaware that I should not use a space, i would choose something different, than now have to remember for this site only, i now have to add a dash instead of a space.

  • bigt11

    I manually added some checks to the registration page. Im checking for a valid email, 6 character for a password, and alphanumeric plus - and _ for the password and username

    open
    \www\wp-content\plugins\membership\membershipincludes\classes\membershippublic.php

    for Buddypress, find validatepage1bp - for regular find 'validatepage1

    UNDER

    if(username_exists(sanitize_user($_POST['signup_username']))) {
    	$error->add('usernameexists', __('That username is already taken, sorry.','membership'));
    }

    ADD

    //TAO adding a check to make sure that the e-mail is a valid email
    									if(!filter_var($_POST['signup_email'], FILTER_VALIDATE_EMAIL))
    										{
    										$error->add('passmatch', __('The email you entered is not a valid email address.','membership'));
    										}
    
    									//TAO adding a check to make sure that the username does not have any weird characters
    									if(!preg_match("/^([-a-z0-9_-])+$/i", $_POST['signup_username']))
    										{
    										$error->add('passmatch', __('The username you are using has illegal characters.  You may use a-z , A-Z , -(dash) , _(underscore)','membership'));
    										}
    
    									//TAO adding a check to make sure that the password does not have any weird characters
    									if(!preg_match("/^([-a-z0-9_-])+$/i", $_POST['signup_username']))
    										{
    										$error->add('passmatch', __('The password you are using has illegal characters.  You may use a-z , A-Z , -(dash) , _(underscore)','membership'));
    										}
    
    									//TAO adding a check to make sure that the password is at least 6 characters
    									$TAO_password_count = strlen($_POST['signup_password']);
    									if($TAO_password_count < 6)
    										{
    										$error->add('passmatch', __('Your password must be at least 6 characters','membership'));
    										}

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.