Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.
Please upgrade to 2.3 here. The 2.2 and earlier branches are no longer being updated.

Restrict member from signing up with the word "admin" as username

Please how do i restrict members from signing up with the word "admin" as username?

Comments

  • peregrineperegrine MVP
    edited October 2015

    what do you mean by signing up? do you mean registering (new account) or signing (logging) in?

    you said you were enlightened, yet, still pose ambiguous question (at least to me).
    is it not clear?

    http://vanillaforums.org/discussion/comment/234548/#Comment_234548

    if you mean registering.

    • create an account yourself called admin and give it a strong password (and if you don't plan on using account you could give it the role guest).

    if you mean signing in.

    • change the name of admin user name to something else.
    • create an account yourself with admin username and give it a strong password (and if you don't plan on using account you could give it the role guest).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • I don't mean to confuse anyone with my questions @peregrine and thanks for always being quick to provide answers to all my questions.

    If register is synonymous to sign up then I guess signing in is synonymous to registering.

    In my question above, I mean restricting members from registering with the word "admin" as username. Thanks for your answer. I'll do just that.

  • hgtonighthgtonight ∞ · New Moderator
    edited October 2015

    @htweet1 You could override the ValidateUsername function in your bootstrap early file to black list any number of words. I posted a simple example function below, but all you need to do is return false if there is any match for your list. If it makes it past your black list, you could then do the standard validation:

    function ValidateUsername($Value, $Field = '') {
       // check against black list
       $blacklist = array('admin', 'official', 'any string');
       $shortName = strtolower($Value);
       foreach($blacklist as $notCoolWord) {
         if(strpos($shortName, $notCoolWord) !== false) {
           return false;
         }
       }
    
       // Do standard validation as well
       $ValidateUsernameRegex = ValidateUsernameRegex();
    
       return ValidateRegex(
          $Value,
          "/^({$ValidateUsernameRegex})?$/siu"
       );
    }
    

    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.

Sign In or Register to comment.