Hi,
The BuddyPress Username Change plug in allows a user to change their user name to to include a space – e.g. “User Name”
This is causing issues in other areas of the site… is there a way to prevent usernames having a space in them? (and possibly also being able to exlude other characters which could cause invalid results e.g /\*%@ could cause other issues
Thanks!
Hello Gordon,
Thank you for posting. Please try the following code. It will allow space in username. You can find more regular expressions to avoid special characters.
/** * Validate user name * * @param WP_Error $error Error object. * @param string $new_user_name New user name. * * @return string */ function buddydev_validate_user_name( $error, $new_user_name ) { if ( $error->has_errors() ) { return $error; } if ( preg_match('/\s/',$new_user_name ) ) { $error->add( 'contains_spaces', __( 'User name can not have space in it' ) ); } return $error; } add_filter( 'bp_username_changer_validation_errors', 'buddydev_validate_user_name', 10, 2 );
Regards
Ravi
Viewing 4 posts - 1 through 4 (of 4 total)
The topic ‘ [Resolved] Username changer allows spaces in username – how can this be blocked’ is closed to new replies.
This topic is: resolved