WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Allowing backslashes in usernames (2 posts)

  1. topquark
    Member
    Posted 7 years ago #

    How do I configure or what file can I edit to allow backslashes in usersnames. I'm setting a weblog that requires usernames of the form 'Domain\Userid'. I have the latest WordPress running but when I try to create a new account of the form 'Domain\Username', I get Invalid username error message.

    Any help or pointers is appreciated. Thanks.

  2. topquark
    Member
    Posted 7 years ago #

    I fixed the problem by updating the regular expression in the sanitize_user function in wp-includes/functions-formatting.php to allow backslashes.

    Updated
    $username = preg_replace('|[^a-z0-9 _.\-@]|i', '', $username);

    To
    $username = preg_replace('|[^a-z0-9 _.\-@\\\\]|i', '', $username);

    For those not wanting to modify the WordPress code, I found a similar need wrapped as a WordPress plugin, namely wp-allowdashes. This provided me with a template to create wp-allowbackslashes which can be accessed from here

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags