Answer the question
In order to leave comments, you need to log in
How to limit the number of sites on WordPress multisite?
Good afternoon.
The question is. There is a grid of sites on WordPress Multisites. I would like to know how you can limit the number of sites created in this grid?
Answer the question
In order to leave comments, you need to log in
Good day.
If you open the wp-admin\network\site-new.php file, you can see how the processing is going:
Developers directly check the action and data transfer without any hooks
if ( isset( $_REQUEST['action'] ) && 'add-site' === $_REQUEST['action'] ) {
check_admin_referer
// 1
add_action('check_admin_referer',function($action){
$blog_count=get_blog_count();
if(is_network_admin()&&isset($_REQUEST['action'])&&'add-site'===$_REQUEST['action']&&$blog_count==2){
wp_die(__('Достигнут лимит','VAB'));
}});
// 2
$blog_count=get_blog_count();
if(is_network_admin()&&isset($_REQUEST['action'])&&'add-site'===$_REQUEST['action']&&$blog_count==2){
add_action('check_admin_referer',function($action){
// if('add-blog'!==$action){return;}
wp_die(__('Достигнут лимит','VAB'));
});}
// ... другие аналоги
do_action( 'network_site_new_form' );
buttons for creating in the markup before output, and then styles and scripts are connected. Can take advantage add_action('network_site_new_form'
and stop everything afterrequire_once ABSPATH . 'wp-admin/admin-footer.php';
add_action('network_site_new_form','action_function_name_6729');
function action_function_name_6729(){
$blog_count=get_blog_count();
if($blog_count==2){exit();}
}
add_action("admin_print_scripts-site-new.php",'my_admin_scripts');
function my_admin_scripts(){
$blog_count=get_blog_count();
if($blog_count==2){
exit('<center><strong style="font-size:33px;">'.__('Достигнут лимит создания поддоменов','VAB').'</strong></center>');}}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question