Reserve Site Names on the Network
Blocks signups for site names you want to keep, such as shop, support or your brand names, on top of WordPress's built-in reserved list.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
$wpide_reserved = array( 'shop', 'store', 'support', 'help', 'admin', 'login', 'api', 'docs', 'status', 'billing' ); // Lower case.
add_filter( 'subdirectory_reserved_names', function ( $names ) use ( $wpide_reserved ) {
return array_merge( $names, $wpide_reserved );
} );
add_filter( 'wpmu_validate_blog_signup', function ( $result ) use ( $wpide_reserved ) {
if ( ! is_super_admin() && in_array( strtolower( (string) $result['blogname'] ), $wpide_reserved, true ) ) {
$result['errors']->add( 'blogname', 'That site name is reserved. Please choose another one.' );
}
return $result;
} );
Notes
Names are compared in lower case; add as many as you need.
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.