This topic has 8 replies, 5 voices, and was last updated 10 years by edecastro05.

  • Author
  • #1749
     mcgreggor
    Participant

    Users who register with spaces in their username (e.g. “John Zorn”) aren’t able to log in because the spaces are converted to hypens (e.g. “john-zorn”). The user however is unaware of this and will try to login with the spaces and uppercase characters resulting in an “unknown user” error.

    This bug is not related to your theme but a general Buddypress bug. For now I added some instructions below the field by editing general-register-modal but I was wondering if it’s possible to add extra validation to the name field so that spaces and uppercase characters are no longer allowed?

    #1794
     SQadmin
    Keymaster

    Hi,
    You can restrict users from registering with space in the username:

    COPY CODE
    
    add_action('bp_init','bpdev_remove_bp_pre_user_login_action');
    function bpdev_remove_bp_pre_user_login_action(){
     remove_action( 'pre_user_login', 'bp_core_strip_username_spaces' );
    }
     
    //add a filter to invalidate a username with spaces
    add_filter('validate_username','bpdev_restrict_space_in_username',10,2);
    function bpdev_restrict_space_in_username($valid,$user_name){
     //check if there is an space
     if ( preg_match('/\s/',$user_name) )
     return false;//if myes, then we say it is an error
     return $valid;//otherwise return the actual validity
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1805
     mcgreggor
    Participant

    Thanks!

    #3308
     Josiah
    Participant

    Where does that code go? theme/functions.php?

    #3533
     SQadmin
    Keymaster

    Hi, This goes to sweetdate-child/functions.php
    Make sure to have the child theme activated

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #3582
     Josiah
    Participant

    Worked great!

    #22463
     edecastro05
    Participant

    Hello Robert,
    Would you be able to repost the code? The link appears it has expired.
    Thank you

    #22948
     Abe
    Keymaster

    Hello, I have updated the code above. Droplr files seem that are no longer accessible.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    ---
    @ SeventhQueen we do our best to have super happy customers. Thanks for being our customer.

    #22994
     edecastro05
    Participant

    Thank you

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Buddypress bug: users with spaces in their usernames can’t register’ is closed to new replies.

Log in with your credentials

Forgot your details?