#4622 closed defect (bug) (duplicate)
Spaces allowed in screen names since 1.6 update
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 1.6 |
Component: | Members | Keywords: | |
Cc: | mrsmegbateman@…, mercijavier@…, inderpreet99, deltafactory, j_dorocak@… |
Description
More details here:
http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/1-6-allowing-users-to-register-with-spaces-in-sn-1/?#post-141606
basically since the 1.6 update, the system has allowed people to register with spaces in their usernames AND with uppercase characters. The spaces are being converted to hyphens, but the user is unaware of that since they never receive their username via email after registering. This has become a customer service NIGHTMARE!
Attachments (1)
Change History (25)
#2
@
12 years ago
- Component changed from Core to Members
- Keywords dev-feedback added
- Version changed from 1.6.1 to 1.6
BuddyPress made a change in 1.6 to validate usernames against WordPress' validate_username() function.
Apparently, that function allows spaces.
I can see how this is a regression from v1.5; I'm going to see if the other devs have a problem with adding back the space check.
#3
@
12 years ago
Where are spaces being converted to hyphens? I don't see it in validate_username()
or in sanitize_user()
(which validate_username()
uses). It's possible that there's a stray filter in there or something.
In any case, I am wary of adding our own username validation back in. We're using WP for authorization, so we should have exactly the same restrictions on usernames that WP has.
#4
@
12 years ago
The hyphens are caused by the pre_user_login
filter. We could remove that filter and that would probably address this issue; we'd need to do some testing to see what would happen though especially with profile URLs and user_login vs. user_nicename.
If you use a space in the username, an error will not be shown when you submit the form. validate_username() is responsible for this.
#5
@
12 years ago
- Milestone changed from Awaiting Review to 1.7
- Severity changed from critical to normal
We could remove that filter and that would probably address this issue; we'd need to do some testing to see what would happen though especially with profile URLs and user_login vs. user_nicename.
Right. Aesthetically, I would like to get rid of this filter, but as you note, we need to research what's going to happen. The only problem would be with username-compatibility mode, I think (since we use user_nicename by default). In those cases, I wonder if we can just fix the issue with the judicious use of urlencode()
and urldecode()
.
Let's figure something out for 1.7, if we can.
#6
follow-up:
↓ 7
@
12 years ago
Not keen on interfering with username validation again; that's why we took it out.
but the user is unaware of that since they never receive their username via email after registering.
Emails not being received is beyond the scope of the ticket. We could add the username to the 'activate your account' email.
#7
in reply to:
↑ 6
@
12 years ago
Replying to DJPaul:
but the user is unaware of that since they never receive their username via email after registering.
Emails not being received is beyond the scope of the ticket. We could add the username to the 'activate your account' email.
I never said emails weren't being received, but that there is no way of the user knowing that their desired username was modified with hyphens since the activation email doesn't mention their username.
Is there any way this can be worked around until there's an actual fix? I'm pretty flabbergasted that this is the first time the bug has been reported here, since there's dozens of threads in the support forums about this customer service nightmare.
#8
@
12 years ago
Is there any way this can be worked around until there's an actual fix?
To prevent the conversion of spaces to hyphens:
remove_action( 'pre_user_login', 'bp_core_strip_username_spaces' );
To keep the conversion in place but throw an error during registration when someone attempts to create a user with spaces in the username, a quick and dirty fix is:
function bp_4622_check_for_spaces_at_registration( $valid, $username ) { if ( false !== strpos( $username, ' ' ) ) { $valid = false; } return $valid; } add_filter( 'validate_username', 'bp_4622_check_for_spaces_at_registration', 10, 2 );
Haven't tested it, but it should result in the "Only lowercase letters and numbers allowed" error being thrown.
We could add the username to the 'activate your account' email.
These seems like a sensible thing to do, regardless of how the username validation stuff is resolved.
#10
@
12 years ago
Recalled this ticket when I was reading @sbrajesh's post re same issue
#11
@
12 years ago
- Milestone changed from 1.7 to Future Release
I'm bumping this from 1.7 to help clear the milestone. This ticket's been up for 3 months and no-one's suggested a good solution to this problem yet.
#13
@
12 years ago
- Cc deltafactory added
Weighing in that I'd like to see this fixed earlier in the name normalization process.
For some added complexity, we use WooCommerce's registration forms to create the user. In the current production version, they improperly handle when the $user_id comes back as a WP_Error object. The resulting cast to int messes up the admin user: no fun. I've already submitted a patch for this.
Our current solution is to add a filter for sanitize_user
(which I believe validate_username()
calls). I couldn't use bp_core_strip_username_spaces()
because it uses username_exists()
which eventually calls sanitize_user()
resulting in an endless loop until memory_limit was reached.
I understand that it's a tricky issue to fix in a compatible way. I think sanitize_user
is the likely choice.
#14
@
12 years ago
The WooCommerce issue sounds like a nasty bug, though as you note, it's not really ours to fix.
If you're having problems with an infinite loop, you can fix it like this:
function my_sanitizing_function() { remove_filter( 'sanitize_user', 'my_sanitizing_function' ); $foo = bp_core_strip_username_spaces( $bar ); /// etc } add_filter( 'sanitize_user', 'my_sanitizing_function' );
I'll reiterate the core team's belief that BP has no business intervening in the username validation process. If you want to impose specific username requirements, there should be core filters in place to allow you to do so. I haven't seen any compelling reason why BP needs to add any global restrictions on top of WP's.
That said, it does look like there's still an issue to be addressed here, which is that sometimes BP replaces spaces with hyphens but doesn't tell the user about it. We need to clear up this situation with better error reporting. As far as I can see, that's the reason the ticket is still open.
#15
@
12 years ago
I hope this gets fixed in BP 1.7. I reported this in Ticket #4838, which was closed because it duplicated this ticket. In #4838 I described what amounts to a workaround:
With BuddyPress1.7Beta1 ACTIVATED on WordPress 3.5.1, when I Add New User named "New Person", the resulting item in the All Users menu comes up as "New-Person".
When I DEACTIVATE BuddyPress1.7Beta1 and Add New User named "Sven Notmyname", NO HYPHEN IS INSERTED. And the resulting item in the All Users menu comes up as "Sven Notmyname".
When I re-ACTIVATE BuddyPress1.7Beta1, and look at the All Users menu:
The entry for "New Person" shows "New-Person". [See screen shot file. [in #4838]]
The entry for "Sven Notmyname" shows "Sven Notmyname". [NO HYPHEN ADDED]
But this is a pain.
Anyway, thanks for the GREAT plugin.
Love and peace,
Joe
#17
@
12 years ago
- Cc j_dorocak@… added
When I click on the More details here link in the ticket, i get "Error 404 - Destination Not Found".
I don't have too much experience with WordPress/BuddyPress, but maybe i can do some research that will help.
Anyway, thanks for the GREAT plugin.
Love and peace,
Joe
#18
@
12 years ago
Not sure why the original link is broken, but here's the thread: http://buddypress.org/support/topic/1-6-allowing-users-to-register-with-spaces-in-sn/
#19
@
12 years ago
- Keywords has-patch added; needs-patch removed
01.patch
allows users to register with spaces.
Because we're allowing users to register with spaces, there are a couple of things that needed to be addressed if 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE'
is defined.
The patch addresses:
- Member permalinks in the member loop shouldn't fallback to
user_nicename
when a space is found in the username
- For @mentions to work, we cannot allow spaces to be used, so in the patch, we will always use the
user_nicename
.
- Needed to add additional template functions so we could grab the logged-in user nicename and the displayed user nicename to be used for the @mention name in the member header.
The big problem here is changing the member-header.php
template to use the new template function.
This is a backpat problem for themes that have already overriden member-header.php in their custom themes.
I see two options here:
- Make the change in the member-header.php and do a post on bpdevel.wordpress.com about this.
- Do not make the change and instead filter
bp_displayed_user_username()
to use theuser_nicename
for the member header only. This kinda sucks.
This is only a problem if 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' is defined and if there are users with spaces in their user_login
.
I totally agree with you, this is really confusing for new users. Anyway, why is it a problem to allow useres "real" spaces? I would appreciate it.