Skip to content

Instantly share code, notes, and snippets.

@bappi-d-great
Created September 8, 2015 19:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bappi-d-great/509d0e6163dc39602942 to your computer and use it in GitHub Desktop.
Save bappi-d-great/509d0e6163dc39602942 to your computer and use it in GitHub Desktop.
Create subsite when the site name is reserved in multisite
<?php
add_filter( 'wpmu_validate_blog_signup', 'wpmu_validate_blog_signup_cb' );
function wpmu_validate_blog_signup_cb( $result ) {
$current_site = get_current_site();
if ( ! domain_exists( $result['domain'], $result['path'], $current_site->id) ) {
if ( username_exists( $result['blogname'] ) ) {
if ( ! is_object( $result['user'] ) || ( is_object($result['user']) && ( $result['user']->user_login != $blogname ) ) ) {
$errors = $result['errors'];
$errors->remove( 'blogname' );
$result['errors'] = $errors;
}
}
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment