Minimum Site Name Length for Signups
Requires new site names to be at least a set number of characters (WordPress only asks for four), cutting down on throwaway and squatted names.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
$wpide_min_length = 6; // Minimum characters.
add_filter( 'wpmu_validate_blog_signup', function ( $result ) use ( $wpide_min_length ) {
if ( ! is_super_admin() && strlen( (string) $result['blogname'] ) < $wpide_min_length ) {
$result['errors']->add( 'blogname', sprintf( 'Site names must be at least %d characters long.', $wpide_min_length ) );
}
return $result;
} );
Notes
Change $wpide_min_length. Super admins creating sites are not restricted.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.