I read the above article before. We want to add spaces.
There’s no changes that you need to make. WordPress does allow spaces in usernames.
In multisite instances, spaces are not allowed, for a very good reason. This cannot be changed. However, in normal single site instances, spaces are accepted in usernames just fine.
We do have buddypress. It does not allow spaces.
If you are not on multisite, You will need to enable username compatibility for BuddyPress.
Put the following code in bp-custom.php
define( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE', true );
For more details, Please see
https://codex.buddypress.org/getting-started/customizing/changing-internal-configuration-settings/
Thank you. I will give it a try.
I added a file bp-custom.php with the code to the wp-content/plugin. New users registering still cannot add spaces.
Hi,
Just to be sure, I tested again.
1. At the moment, It is going to be real difficult to allow space. BuddyPress strips out the space on line 1792 bp-members-functions.php
$user_login = preg_replace( '/\s+/', '', sanitize_user( $user_login, true ) );
And there is no way to avoid it at the moment. No filter available there.
My previous suggestion will help only in making the profiles available when they contain dot or spaces not in registering them.
A temporary solution may be to filter on ‘bp_after_bp_core_signups_add_args_parse_args’ and change the value of ‘user_login’ if $_POST[‘signup_username’] is set and valid( See BP_Signup::add() ). That is a hack that will most probably work but is too ugly for my taste.
if it is too ugly then I will not take the chance! Thank you.