• Hello,

    I am trying to set minimum username length at registration up to 4 characters. How to set a minimum username length in wordpress.

    I am not a big fan of plugin.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter jessicana

    (@jessicana)

    Anyone? Any help?

    Add this to the end of your theme’s functions.php:

    /**
     * Additional registration checks.
     *
     * This filter is documented in wp-includes/user.php
     */
    function my_registration_errors( $errors, $sanitized_user_login, $user_email ) {
    	if ( strlen( $sanitized_user_login ) < 5 ) {
    		$errors->add( 'username_too_short', __( '<strong>ERROR</strong>: Username must be at least 5 characters.' ) );
    	}
    	return $errors;
    }
    add_filter( 'registration_errors', 'my_registration_errors', 10, 3 );

    Thread Starter jessicana

    (@jessicana)

    @chris Dillon

    Thanks for the reply. By the way, if I use wordpress multisite, the minimum username is set to four. Right?

    What about password length and how to ask for a customized wordpress password? For example, by saying password must be 6 characters length and must have numbers and special characters?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Set minimum username length at registration’ is closed to new replies.