Using the regex posted by Moaz (and adding capitals), we will need to hook into the registration_errors
filter:
// Restrict username registration to alphanumerics
add_filter('registration_errors', 'limit_username_alphanumerics', 10, 3);
function limit_username_alphanumerics ($errors, $name) {
if ( ! preg_match('/^[A-Za-z0-9]{3,16}$/', $name) ){
$errors->add( 'user_name', __('<strong>ERROR</strong>: Username can only contain alphanumerics (A-Z 0-9)','CCooper') );
}
return $errors;
}
Related Posts:
- Can I hook into user registration *before* a user is created?
- Problem with Hebrew characters in username
- How to prevent certain usernames from being registered?
- White spaces in username give 404 on author page
- auto assign sequence base username while registration
- How to allow wordpress to create username with symbols like +
- 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
- Is it possible to remove username field from the registration page? If so, how?
- users table – user_name vs. nicename
- Google Apps login in wordpress
- Changing the username character limit from four to less characters
- How to limit user registration to a specific set of domains?
- Stop spam users from registering without disabling user registration?
- 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?
- How to prevent spam users registering even with registration disabled
- Email as Username in registration
- Set “Display name publicly as” to be usernames by default
- Creating a Closed WordPress Community Using Referral Codes
- 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 to allow more than one registered user to have the same email?
- How to check username availability with ajax at registration
- Is there a maximum length to user passwords?
- Checked checkbox?
- On user registration, if welcome mail sent, add post with new user as author
- limit characters when posting from form
- 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
- Adding register & login in WordPress website
- registration form not working
- How can I disable all client side new accounts without disabling new user accounts?
- Adding character count and limit in comments, modifying labels and fields – jetpack
- 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
- Show ellipsis (…) only if the number of characters exceeds limit defined in substr
- 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
- Restrict partially matching usernames
- How to register a user to a group by an invitation code?
- Register form how to get Total Control of it
- Custom user registration
- 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 registration fields not validating
- 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
- Controller functionality – User not logged in/ redirect to registration page (not wp_login)
- wp_register() displays logged in user as site admin
- Create a post with user_register doesn’t create title
- User activation in wordpress
- Why is wp_new_user_notification not working?
- 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
- Not receiving any sign up mail, when user registers… Both admin & user
- WordPress is sending an empty email after using wp_insert_user
- How to auto-generate random numbers in username?
- wp_insert_user if user exists
- Author name length character limit?
- 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
- Custom user creation and auto login problem
- How to generate Registration no
- Prevent registration except through form
- 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
- wp-signup.php example template
- Limit access to a page
- A conditional button
- enqueue style google fonts in functions.php in array?
- Fields in register page is pre-filled out with name and email
- Group users by meta_value
- Change default error message “This email address is already in use” when registering a new user in WordPress using Caldera Forms
- Run custom validation only if all other wordpress registration form validation was successful
- Truncating characters in Advanced Custom Fields works some places but not others?