Created
September 8, 2015 19:32
-
-
Save bappi-d-great/509d0e6163dc39602942 to your computer and use it in GitHub Desktop.
Create subsite when the site name is reserved in multisite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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