WP-Members: Membership Framework
[resolved] usable symbols for username (3 posts)

  1. HoneyBB
    Posted 2 years ago #

    I would like to know all of usable symbols for username.

    Does anyone know that?



  2. Chad Butler
    Plugin Author

    Posted 2 years ago #

    There is not a direct answer for that since it is dependent upon certain elements of WordPress. The plugin uses the WP function validate_username to during registration to determine the validity of a requested username. Since validate_username can be filtered, and it uses the function sanitize_user which can also be filtered, the answer to what is a usable symbol is "it depends."

    In most cases, if you aren't changing anything with WP's username validation, it is going to remove unsafe characters (tags, octets, and entities).

    If $strict is true for sanitize_user, then it will remove all non-ASCII characters, which essentially leaves you with alphanumeric characters plus _, ., -, *, @, and space.

    So if you want to limit it, you can do so with the sanitize_user filter.

    There is also an action hook in the plugin that would allow you to do your own validation. wpmem_pre_register_data comes after all the default validation is complete, but before the user is inserted. That would be the final point to hook into and return an error based on any criteria you wanted (such as not allowing spaces in usernames even if WP's sanitize_user is strict, which would allow them).

  3. HoneyBB
    Posted 2 years ago #

    Thank you for your kind reply.
    It helps me a lot.

    Best Regards,

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-Members: Membership Framework
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.