Last active
September 21, 2022 18:31
-
-
Save bappi-d-great/7b3828009bfd7015b526 to your computer and use it in GitHub Desktop.
WordPress Multisite - only allow one site per user
This file contains hidden or 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 | |
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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for nice comment @ugotsta 😄