Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPress Multisite - only allow one site per user
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');
Copy link

Ugotsta commented Aug 7, 2014

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

Copy link

bappi-d-great commented Nov 24, 2014

Thank you for nice comment @Ugotsta 😄

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