Disable or limit the creation of additional sites (blogs) for subsites

I know this has been asked before... is it possible to limit or restrict the creation of additional blogs? I'm just wondering if there's any update to the question that's been asked a few times (a few years ago). Thanks!
S

  • Adam Czajczyk

    Hello Shayne,

    I hope you're well today and thank you for your question!

    I'm not sure whether you are asking about WordPress itself or about our Pro Sites plugin but neither of those has such a "limiting" feature implemented.

    This code should however help:

    <?php
    function wpms_one_blog_only($active_signup) {
    	$blogs_number = 0;
    	// get the array of the current user's blogs
    	$blogs = get_blogs_of_user( get_current_user_id() );
    	// all users may be members of blog 1 so remove it from the count, could be a "Dashboard" blog as well
    	if ($blogs["1"]) unset($blogs["1"]);
    	//if the user still has blogs, disable signup else continue with existing active_signup rules at SiteAdmin->Options
    	$n = count($blogs);
    	if($n > $blogs_number){
    		$active_signup = 'none';
    		echo '';
    	} else {
    		$active_signup = $active_signup;
    	}
    	return	$active_signup; // return "all", "none", "blog" or "user"
    }
    add_filter('wpmu_active_signup', 'wpms_one_blog_only');

    Putting it to your site as a "MU plugin" and setting up the value of "$blog_number" variable should limit number of allowed blogs per user up to that number.

    To use the code as "mu plugin" please create an empty file with a PHP extension, put the code inside and upload the file to the "/wp-content/mu-plugins" folder of your site.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.