Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

automatic removal of spaces in username

Hi there,

Right now, if user John F connects to the forum for the first time, he gets assigned a user name "John F", but I'd prefer usernames to have no spaces (i.e. JohnF) or alternatively, underscores or spaces (i.e. John.F or John_F).

Is there a way to automate the removal of spaces in usernames (or replacement w/ an underscore or dot) during the automatic creation of a member's username in a forum?

Thanks in advance

«1

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Registration is not very pluggable as of right now.

    As far as I know, there is no way to do it without hacking the core.

    What version number of Vanilla are you running?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • hbfhbf wiki guy? MVP

    @hgtonight said:
    Registration is not very pluggable as of right now.

    As far as I know, there is no way to do it without hacking the core.

    What version number of Vanilla are you running?

    seems like a lot of places where you would need to handle it, but a simple regex could provide the translation. likely a category 4 PITA.

    http://homebrewforums.net/plugin/page/customplugins

  • @hgtonight I'm running 2.0.18.8 and jsConnect 1.0.3b.

    How much core hacking do you think would be involved?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Just adding something to the registration file , please follow the steps in the other discussion I mentioned it is not hard to do it, just remember what and where you did it and keep a note of it, because it will be overwritten when upgrading and you will need to do it again.

  • hbfhbf wiki guy? MVP

    @vrijvlinder said:
    Just adding something to the registration file , please follow the steps in the other discussion I mentioned it is not hard to do it, just remember what and where you did it and keep a note of it, because it will be overwritten when upgrading and you will need to do it again.

    are you sure? I dont really know.

    so, are you saying this is a category 2 or 3 change? :)

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Well that depends on how badly they need the intel lol there is room for negotiation ....

    It is as you said above just a matter of changing one thing in the Validation regex.

    so possibly still Category One but since the editing is in the core without warranty, then I think it's a freebee since the info is public domain, you can't charge for existing info unless they refuse to search B)

  • hbfhbf wiki guy? MVP

    @vrijvlinder said:
    Well that depends on how badly they need the intel lol there is room for negotiation ....

    It is as you said above just a matter of changing one thing in the Validation regex.

    so possibly still Category One but since the editing is in the core without warranty, then I think it's a freebee since the info is public domain, you can't charge for existing info unless they refuse to search B)

    but changing the validation regex wont have any effect on jsconnect. i dont think you can submit a user name with a space in it via the normal signup forms, where the validation is applied. its js connect that is creating the garbage names, and signing people in to them. i think the changes would effect js connect and a few other pieces of core potentially.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    but changing the validation regex wont have any effect on jsconnect.

    Right , they asked:

    How much core hacking do you think would be involved?

    This only answers the core hacking not the js connect sorry :(

  • hbfhbf wiki guy? MVP

    @vrijvlinder said:
    This only answers the core hacking not the js connect sorry :(

    back to a category 4 :)

  • hgtonighthgtonight ∞ · New Moderator

    As others stated is connect bypasses name validation by design. IF I were approaching this problem, I would look into validating/correcting the name in jsConnect.

    Some type of automatic replacement will have to be done along with validation that ensure the new name doesn't already exist.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited October 2013

    What you could also do while the other is figured out , is add a note on the login register form of js connect

    In the class.jsconnect.plugin.php find this in line 61 and replace with this

    $Result = '<div style="display: none" class="JsConnect-Container ConnectButton Small UserInfo" rel="'.$Url.'">
             <div class="JsConnect-Guest">'.Anchor(sprintf(T('Sign In with %s'), $Provider['Name']), $SignInUrl, 'Button SignInLink').$RegisterLink.'</div>
             <div class="JsConnect-Connect"><a class="PopupWindow ConnectLink" popupHeight="300" popupWidth="600">'.Img('/applications/dashboard/design/images/usericon.gif', array('class' => 'ProfilePhotoSmall UserPhoto')).'<span class="Username"><span class="No-Spaces">No-Spaces</span></span><div class="ConnectLabel">'.sprintf(T('Sign In with %s'), $Provider['Name']).'</div></a></div>
          </div>';
    

    Let me know if it works to show that No-Spaces message

  • Hi guys, thanks for the feedback.

    @vrijvlinder, after adding that code, I didn't see the message appear anywhere. Everything worked as normal, it seems. Should I be looking somewhere specific to see that message displayed?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited October 2013

    The message is supposed to show next to the title UserName

    In theory it should look like this

    UserName-No-Spaces

    Maybe you can experiment with the location of that span . It may be showing but it may be hiding behind or under something. Look in web inspector to see if the span is being rendered. If it is then write a css rule for it.

  • hbfhbf wiki guy? MVP

    @vrijvlinder said:
    The message is supposed to show next to the title UserName

    In theory it should look like this

    UserName-No-Spaces

    Maybe you can experiment with the location of that span . It may be showing but it may be hiding behind or under something. Look in web inspector to see if the span is being rendered. If it is then write a css rule for it.

    but if he's using jsconnect for the login, then he's not using the vanilla login form. it's being bypassed entirely. the credentials are passed from the upstream application via jsconnect into vanilla.

    you would have to restrict user names in the upstream system for that sort of approach to work, which it wont if the users have already been created. best option is to use a string replacement/encoding scheme in jsConnect

  • I'm surprised this hasn't been brought up before, considering a number of folks use jsConnect. When these users have their members replying to each other in the forums, their replies are broken (since @name+initial won't register the same as one string, @nameInitial, no spaces)

    @hbf I'm willing to try editing my jsConnect's php files, just don't know where to look or what to implement. You mentioned string replacement / encoding. Suggestions / tips on how to make it happen, and where?

  • @hbf @vrijvlinder @hgtonight another observation: I can't even change my members' usernames manually, because even if I do so (under users in the dashboard), once the user signs back in, jsConnect automatically changes it back to the first name last initial, with a space.

  • hgtonighthgtonight ∞ · New Moderator

    If you are only looking to do this for mentions to work properly, trying adding support for usernames with spaces in that function.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    The thing is their names are pre-made from whatever they used to connect. I think the best approach is to try and change the names once they hit the Database.

    I am sure there is a way to change all user names that have a space with some kind of script. I am not sure how to implement REPLACE(string,' ','') so here are some resources

    http://php.net/manual/en/function.str-replace.php

    http://www.php.net/manual/en/function.preg-replace.php

    http://php.net/manual/en/function.preg-replace-callback.php

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited October 2013

    It may be possible to use jquery in your theme , but this is untested , it is just an idea .There seem to be various methods to achieve this. This below adds a dash in the spaces

    $(document).ready(function() {
    
        var strNewString = $('.Item .Author a').html().replace(/\./g,'-');
    
        $('.Item .Author a').html(strNewString);});
    
  • Would I be testing this by adding to class.jsconnect.plugin.php?

    @vrijvlinder said:
    It may be possible to use jquery in your theme , but this is untested , it is just an idea .There seem to be various methods to achieve this. This below adds a dash in the spaces

    $(document).ready(function() {
    
        var strNewString = $('.Item .Author a').html().replace(/\./g,'-');
    
        $('.Item .Author a').html(strNewString);});
    
Sign In or Register to comment.