We need to add a filter to ‘sanitize_user’.
Here is the sample code that will work for you.
add_filter( 'sanitize_user', 'tubs_sanitize_user', 10, 3); function tubs_sanitize_user($username, $raw_username, $strict) { $new_username = strip_tags($raw_username); // Kill octets $new_username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $new_username); $new_username = preg_replace('/&.?;/', '', $new_username); // Kill entities // If strict, reduce to ASCII for max portability. if ( $strict ) $new_username = preg_replace('|[^a-z0-9 _.\-@+]|i', '', $new_username); return $new_username; }
Note: This code is the modified version of the original WordPress sanitize_user function.
Related Posts:
- How to prevent certain usernames from being registered?
- White spaces in username give 404 on author page
- auto assign sequence base username while registration
- Restrict certain character combinations in username during registration
- allow only lowercase user registrations
- Create a unique username with validation on wordpress registration
- I have restricted the username to numerical format but not able to integrate the same with PeepSo plugin
- Limit username to specific characters (A-Z and 0-9)
- Is it possible to remove username field from the registration page? If so, how?
- users table – user_name vs. nicename
- Can I hook into user registration *before* a user is created?
- How to limit user registration to a specific set of domains?
- Problem with Hebrew characters in username
- How do I create a user using the new JSON api in 4.7?
- How can i force Display names to be the same as Usernames?
- Insert “New User” and update/set meta data at once
- Send automatic email to user after wp_create_user
- How to disable or protect against disposable email accounts?
- Advice on setting up a site with front end registration
- How to add a description to the user name input field in the registration form?
- How to add a checkbox to registration and user profile?
- wp_create_user hook
- Password field (and confirmation) showing up twice on registration
- How to disable user registration for the default subscriber user role?
- Showing the user’s username in registration email or activation page with BuddyPress [closed]
- How can I find users that didn’t set a password?
- How to check username availability with ajax at registration
- Send custom signup approval email to different Administrators selectively
- After e-junkie payment, send a http post to register user automatically?
- Email confirmation in user registration form without a plugin
- How to add additional information to a user on user creation?
- Invalid key on activation and password reset
- How can I have user registration verify a whether a new user is listed in a table of pre-approved users?
- Mobile User Registration
- Conditionally registering users
- WordPress Register Form
- Creating custom registration and login link in wordpress
- Adding register & login in WordPress website
- registration form not working
- How can I disable all client side new accounts without disabling new user accounts?
- Unique registration for new writers to sign up
- Getting thousands of registration spam
- Custom registration form with different registration process based on what’s selected
- Is that possible show user’s post after user login
- register user only with specific Host name
- Generate long hashed user ID
- Disable New User Registration Email sent to WordPress admin email on 4.9.5
- my custom css file downloads then it STOPS!
- Restrict partially matching usernames
- How to register a user to a group by an invitation code?
- I want to add a tax-ID field in registration form and upon submission, perform a lookup by tax-ID
- Modifying the Default Registeration Page?
- WordPress + bbPress registration user-unfriendly?
- Force display name to nickname wp
- not sending correct link to set the password in registration email [closed]
- wp_insert_user not returning anything
- Custom User Registration script only allowing usernames with 16 characters
- New register email notification sending some fields blank on site admin emai id
- wp_insert_user function not adding password field to database
- Profile picture in registration form WordPress [closed]
- Controller functionality – User not logged in/ redirect to registration page (not wp_login)
- wp_register() displays logged in user as site admin
- loading custom registration template
- Create a post with user_register doesn’t create title
- User activation in wordpress
- Why is wp_new_user_notification not working?
- How to add user registration and signup in WordPress and create members only page?
- Single Sign On or Bridge with in the WordPress WebSites?
- Is there a way to check the email of the user trying to register before he registers?
- signup_user() throws fatal error
- Custom Registration Form Based on user location Woocommerce
- WordPress – Use user meta in ‘user_register’ after new registration
- Action Hook that fires function upon registration at Woocommerce checkout
- My new website registration error
- Not receiving any sign up mail, when user registers… Both admin & user
- I want to give every new registering user a unique key apart from password field for external use
- Is it possible to remove the password field in the registration page in woocommerce?
- How to auto-generate random numbers in username?
- wp_insert_user if user exists
- How to hide username on wordpress registration?
- What’s the Point of Spam Registrations?
- Add custom Date column to “All Users” admin panel in WP
- Can’t figure out how people are registering on my site
- Update a user field with a generated text
- Custom Registration with Select and Upload function
- generate an auto incremented id number when a new user is registered
- Remove wp-login link from auto generated wordpress’s email
- Upon registration, redirect new user to Dashboard
- Disallow google/other email plus and dot tricks when registering?
- disabling emails received by admins every time a new user signs up (function not working)
- how to allow unregistred users to view normal posts [closed]
- Wrong user registration date in wordpress
- A conditional button
- Plugin recommendation for directory site [closed]
- enqueue style google fonts in functions.php in array?
- Fields in register page is pre-filled out with name and email
- Login to comment: not just user and email
- Group users by meta_value
- Run custom validation only if all other wordpress registration form validation was successful
- I want to set the shipping_first_name metadata value to match the first_name metadata value for a User on registration using a function