Skip to content

Instantly share code, notes, and snippets.

@cdillon
Created April 22, 2015 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdillon/59033a52ba9796930e6e to your computer and use it in GitHub Desktop.
Save cdillon/59033a52ba9796930e6e to your computer and use it in GitHub Desktop.
require minimum length for WordPress user login
/**
* 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 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment