• Resolved Surbma

    (@surbma)


    Hi,

    I just wanted to create a new subsite and I got this error message:
    “Sorry, that site is reserved!”

    It seems, there is no way to create a subsite with any of the existing usernames. Is it intentional or a bug?

    If it is intentional, can you please explain why you don’t let to create a subsite with a name of a username?

    Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Never Settle

    (@neversettle)

    Hi There,

    That message is generated by WordPress when you try to create a site with the same name as an existing user. This can happen whether from a user that was created as part of a subsite that was previously created and then deleted, or even if the user was just added separately. (The user can be a member of any existing site, so be sure to verify through /wp-admin/network/users.php).

    The keyword here in that message is “reserved.”

    WordPress reserves site names for existing users because with certain settings it allows users to create blogs and it wants the blog name to match the user name.NS Cloner uses the WordPress blog name validation?to make sure that a new site that is generated the result of a cloning operation is a valid site name and won’t lead to other issues after it is cloned.

    To remedy this situation you have three options:

    1. Delete the user with the same name
    2. Manually edit the DB to change that username and re-use the original for the site
    3. Use a different site name

    Hope this helps!

    Thread Starter Surbma

    (@surbma)

    Hi,

    thank you for your quick reply!

    You say, that you are using the wpmu_validate_blog_signup() function to validate the new site name. It is having only an empty $user object by default and in this case, it is validating the usernames against the new site naming.

    So if you provide the current user in the $user object, it will only validate the same name of the current user, but any other usernames can be used to create a new site.

    So please provide the current user object with the function’s third parameter:

    
    if ( is_user_logged_in() ) {
        $user = wp_get_current_user();
    }
    

    And in your ns-utils.php file in the ns_wp_validate_site() function include the object and add the third parameter to the 171. line code:

    
    $site_signup = wpmu_validate_blog_signup( $site_name, $site_title, $user );
    

    This little modification will allow anybody to create new site even, if it is equal with other users’ usernames.

    I hope you agree with me in this point and add this little modification to make it more useful for anybody. Even you can delete your documentation regarding this “error”.

    Thank you!

    Plugin Author Never Settle

    (@neversettle)

    Hi @surbma,

    Thanks for your input! I’m thinking that $user parameter in wpmu_validate_blog_signup actually behaves a little differently, though. Based off this logic inside that function in ms-functions.php, I believe that it’s actually the reverse of what you described above: if we passed the user parameter there, it would allow the current user to create a site/blog with the same name as their username, but would still not allow any other username. Note how it has a negative comparison of current username and new blogname that would trigger the validation error:

    	if ( username_exists( $blogname ) ) {
    		if ( ! is_object( $user ) || ( is_object( $user ) && ( $user->user_login != $blogname ) ) ) {
    			$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
    		}
    	}
    Thread Starter Surbma

    (@surbma)

    It seems, you are right with this function. It only allows user to create a site with his/her own username, if logged in.

    I just checked, what WP is using under Sites -> Add new page. It is using the wpmu_create_blog() function, which allows the Superadmin to create a site with any name, except with existing names.

    So my other suggestion is to check if user is_super_admin() so you should use the wpmu_create_blog() function instead. In this way, we can really create any new sites just like we could do under Sites -> Add new page.

    Thank you for being open to discuss this step! It would be great to allow superadmins to do what they really can.

    Plugin Author Never Settle

    (@neversettle)

    Hey @surbma – just circling back to let you know we just released an update that includes simplified and improved site validation that should allow admins to create sites with the same subdomain or subdirectory as existing user names.

    Thread Starter Surbma

    (@surbma)

    Thank you guys! It is really a good news!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can’t create a new subsite with the name of any usernames’ is closed to new replies.