Skip to main content
Sebastian
Helper ⭐️⭐️⭐️
June 5, 2020

Restrict users from using a phone number / specific keywords in their username

  • June 5, 2020
  • 15 replies
  • 737 views

How to restrict users from using a phone number as their username

Note: you must be have the community manager/administrator primary role to configure this rule.

  1. Go to Control > Settings > Registration rules
  2. Under username restrictions, turn on the switch for ‘Block registrations with phone numbers in usernames’.
  3. That’s all!

Rule we use to block phone numbers

  • We use the following regex to block phone numbers in usernames: https://regexr.com/3c53v.
  • More generally, this rule blocks any username that is entirely composed of numbers.

End user experience

  • If this setting is enabled, end users will see an error message explicitly mentioning that it looks like they’re trying to use a phone number in their name and asking them to try again.
  • This is a customisable phrase you can change in Control (Module: Forum; Key: validation.username.is.phone.number).

How to restrict users from using specific keywords in their username

Note: you must be have the community manager/administrator primary role to configure this rule.

  1. Go to Control > Settings > Registration rules
  2. Under username restrictions, turn on the switch for ‘Block registrations where username contains any of the following keywords’
  3. Add the keywords you want to block in a comma-separated list.
  4. Hit save changes, and you’re done!

End user experience

  • If this setting is enabled, end users will see an error message explicitly mentioning that their username contains a restricted keyword and asking them to try again.
  • This is a customisable phrase you can change in Control (Module: Forum; Key: validation.username.restricted.text)

    15 replies

    Paul_
    Contributor ⭐️⭐️⭐️⭐️⭐️
    October 27, 2020

    I believe @Ditte wants to prevent email addresses from being used as usernames. My guess is that there is a regex expression you can achieve that with, most likely by preventing users from using the @ alltogether.

    Yes, exactly what I was thinking. Will adding the “@” to the keywords work for preventing e-mail addresses as usernames?

    Paul_
    Contributor ⭐️⭐️⭐️⭐️⭐️
    October 27, 2020

    I believe @Ditte wants to prevent email addresses from being used as usernames. My guess is that there is a regex expression you can achieve that with, most likely by preventing users from using the @ alltogether.

    Yes, exactly what I was thinking. Will adding the “@” to the keywords work for preventing e-mail addresses as usernames?

    Tested it, and it seems to work! Add the “@”, and no more e-mail addresses as usernames.

    Julian
    Gainsight Employee ⭐️⭐️⭐️
    October 27, 2020

    Thanks for clearing this up! :)

    I did not even think about the possibility of users selecting their email address as the username, but of course this is something that could happen… Glad to hear that the solution is that simple, thanks a lot for verfying that it works, Paul!

    I follow my nose, it always knows
    Contributor ⭐️⭐️
    October 15, 2021

    Hi there– I noticed that you use regex in order to block phone numbers from being registered as usernames. Any thoughts about potentially opening up keyword blocking to also be able to use regex, so we can make use of this on our end?

    Contributor ⭐️⭐️⭐️
    December 12, 2022

    This option is amazing, but somehow most newly registered users with a cellphone number as their username on our Community still get through, instead of being blocked. Any idea as to how this is possible? Could it have something to do with how the regex operates?