Skip to content

Instantly share code, notes, and snippets.

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/7b3828009bfd7015b526 to your computer and use it in GitHub Desktop.
Save bappi-d-great/7b3828009bfd7015b526 to your computer and use it in GitHub Desktop.
WordPress Multisite - only allow one site per user
<?php
function wpms_one_blog_only($active_signup) {
// 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 > 0){
$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');
@R3V1Z3
Copy link

R3V1Z3 commented Aug 7, 2014

This is hugely helpful, and great that you took the main blog into account as well. Important snippet, this one! :)

@bappi-d-great
Copy link
Author

Thank you for nice comment @ugotsta 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment