The ms_site_check WordPress PHP filter allows you to override the default blog status check in a multisite network.
Usage
add_filter( 'ms_site_check', 'custom_ms_site_check' ); function custom_ms_site_check( $check ) { // your custom code here return $check; }
Parameters
- $check (bool|null): Whether to skip the blog status check. Default null.
More information
See WordPress Developer Resources: ms_site_check
Examples
Bypass blog status check
Bypass the default blog status check for all sites in a multisite network.
add_filter( 'ms_site_check', '__return_true' );
Allow specific blog ID to bypass status check
Only bypass the blog status check for a specific blog ID (e.g., 5).
add_filter( 'ms_site_check', 'allow_blog_id_5', 10, 1 ); function allow_blog_id_5( $check ) { if ( get_current_blog_id() == 5 ) { return true; } return $check; }
Disable blog status check for specific user role
Disable the blog status check for users with the “editor” role.
add_filter( 'ms_site_check', 'disable_check_for_editor', 10, 1 ); function disable_check_for_editor( $check ) { if ( current_user_can( 'editor' ) ) { return true; } return $check; }
Disable blog status check for specific user
Disable the blog status check for a specific user by their ID (e.g., 10).
add_filter( 'ms_site_check', 'disable_check_for_user_10', 10, 1 ); function disable_check_for_user_10( $check ) { if ( get_current_user_id() == 10 ) { return true; } return $check; }
Custom blog status check
Create a custom blog status check based on a custom meta value.
add_filter( 'ms_site_check', 'custom_blog_status_check', 10, 1 ); function custom_blog_status_check( $check ) { $blog_id = get_current_blog_id(); $custom_status = get_blog_option( $blog_id, 'custom_blog_status', 'active' ); if ( $custom_status == 'inactive' ) { return false; } return $check; }