Resolve WordPress Multi-Site Network Problems
Network Activation Problems
Step 1: Check Network Requirements
`
SLOS → Multi-Site → Network → Requirements Check
`
Network Compatibility Report:
`json
{
“multisite_enabled”: true,
“networkadminaccess”: true,
“superadminprivileges”: true,
“networkactivatedplugins”: [
“slos-legalflowsuite.php”
],
“sitespecificsettings”: true,
“sharedtablesconfigured”: false,
“issues_found”: [
{
“type”: “sharedtablesmissing”,
“severity”: “high”,
“description”: “Shared consent tables not created”,
“fix_required”: true
}
]
}
`
Step 2: Fix Network Activation
`php
// Network activation fix
function fixNetworkActivation() {
// Ensure we’re in network admin
if (!isnetworkadmin()) {
return false;
}
// Create shared tables
createSharedTables();
// Set network-wide options
updatenetworkoption(null, ‘slosnetworkactivated’, true);
updatenetworkoption(null, ‘slossharedtables_created’, true);
// Configure default settings for all sites
setNetworkDefaults();
return true;
}
function createSharedTables() {
global $wpdb;
$sharedTables = [
‘slosconsentlog’ => “CREATE TABLE {$wpdb->baseprefix}slosconsent_log (
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
site_id BIGINT UNSIGNED NOT NULL,
user_id BIGINT UNSIGNED,
consent_categories TEXT,
consenttimestamp TIMESTAMP DEFAULT CURRENTTIMESTAMP,
ip_address VARCHAR(45),
user_agent TEXT,
source VARCHAR(50) DEFAULT ‘direct’,
INDEX idxsiteuser (siteid, userid),
INDEX idxtimestamp (consenttimestamp)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4unicodeci;”,
// Add other shared tables…
];
foreach ($sharedTables as $tableName => $createQuery) {
$fullTableName = $wpdb->base_prefix . $tableName;
if ($wpdb->get_var(“SHOW TABLES LIKE ‘$fullTableName'”) != $fullTableName) {
$wpdb->query($createQuery);
}
}
}
`
Step 3: Verify Network Setup
`sql
— Verify network setup
SELECT
‘sharedtables’ as checktype,
COUNT(*) as tables_found
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE()
AND TABLENAME LIKE ‘wpslos_%’
AND TABLENAME NOT LIKE ‘wp2slos%’;
SELECT
‘networkoptions’ as checktype,
option_name,
option_value
FROM wp_options
WHERE optionname LIKE ‘slos%’
ORDER BY option_name;
`
Site-Specific Settings Conflicts
Step 1: Analyze Site Configurations
`
SLOS → Multi-Site → Sites → Configuration Analysis
`
Site Configuration Report:
`json
{
“total_sites”: 5,
“siteswithslos”: 5,
“configuration_conflicts”: [
{
“conflicttype”: “consentcategories_mismatch”,
“affected_sites”: [2, 4],
“description”: “Sites have different consent category definitions”,
“severity”: “medium”
},
{
“conflicttype”: “bannerposition_inconsistent”,
“affected_sites”: [1, 3, 5],
“description”: “Different banner positions across sites”,
“severity”: “low”
}
],
“recommendedaction”: “standardizesettings”
}
`
Step 2: Standardize Site Settings
`
SLOS → Multi-Site → Sites → Settings Standardization
`
Settings Standardization Process:
`json
{
“standardization_steps”: [
{
“step”: “analyzecurrentsettings”,
“description”: “Collect settings from all sites”,
“status”: “completed”
},
{
“step”: “identifybestpractices”,
“description”: “Determine optimal settings”,
“status”: “completed”
},
{
“step”: “applynetworkdefaults”,
“description”: “Apply standardized settings”,
“status”: “in_progress”
},
{
“step”: “verify_consistency”,
“description”: “Check all sites match standards”,
“status”: “pending”
}
],
“settingstostandardize”: [
“consent_categories”,
“banner_position”,
“cookie_expiry”,
“privacypolicyurl”
]
}
`
Step 3: Apply Site-Specific Overrides
`php
// Site-specific settings management
function manageSiteSpecificSettings($siteId, $settings) {
$networkDefaults = getNetworkDefaults();
$siteOverrides = getSiteOverrides($siteId);
// Merge settings with proper precedence
$finalSettings = array_merge($networkDefaults, $siteOverrides, $settings);
// Validate settings
$validation = validateSiteSettings($finalSettings, $siteId);
if ($validation[‘valid’]) {
updateSiteSettings($siteId, $finalSettings);
return [‘success’ => true];
} else {
return [
‘success’ => false,
‘errors’ => $validation[‘errors’]
];
}
}
function getSiteOverrides($siteId) {
// Get site-specific settings that override network defaults
return getoption(‘slossite‘ . $siteId . ‘overrides’, []);
}
`
Shared Table Issues
Step 1: Check Shared Table Structure
`
SLOS → Multi-Site → Tables → Structure Check
`
Shared Table Analysis:
`json
{
“shared_tables”: [
{
“tablename”: “wpslosconsentlog”,
“exists”: true,
“columns_correct”: true,
“indexes_present”: true,
“sitecolumnexists”: true,
“record_count”: 15420
},
{
“tablename”: “wpsloscookiesettings”,
“exists”: true,
“columns_correct”: false,
“missingcolumns”: [“siteid”],
“indexes_present”: true,
“record_count”: 450
}
],
“issues_found”: [
{
“table”: “wpsloscookie_settings”,
“issue”: “missingsiteid_column”,
“severity”: “high”,
“fix_available”: true
}
]
}
`
Step 2: Fix Shared Table Problems
`sql
— Add missing site_id column to shared tables
ALTER TABLE wpsloscookie_settings
ADD COLUMN site_id BIGINT UNSIGNED NOT NULL DEFAULT 1 AFTER id,
ADD INDEX idxsiteid (site_id);
— Migrate existing data to include site_id
UPDATE wpsloscookie_settings
SET site_id = 1
WHERE siteid = 0 OR siteid IS NULL;
— Update table structure for other shared tables
ALTER TABLE wpslosconsent_log
MODIFY COLUMN site_id BIGINT UNSIGNED NOT NULL DEFAULT 1;
— Add site-specific indexes
CREATE INDEX idxsitetimestamp ON wpslosconsentlog (siteid, consent_timestamp);
CREATE INDEX idxsiteuser ON wpslosconsentlog (siteid, user_id);
`
Step 3: Validate Table Integrity
`sql
— Table integrity validation
SELECT
table_name,
table_rows,
data_length,
index_length,
(datalength + indexlength) as total_size
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = DATABASE()
AND TABLENAME LIKE ‘wpslos_%’
ORDER BY table_name;
— Check for orphaned records
SELECT
‘consentlogwithout_site’ as issue,
COUNT(*) as count
FROM wpslosconsent_log
WHERE siteid NOT IN (SELECT blogid FROM wp_blogs);
SELECT
‘settingswithoutsite’ as issue,
COUNT(*) as count
FROM wpsloscookie_settings
WHERE siteid NOT IN (SELECT blogid FROM wp_blogs);
`
Cross-Site Consent Synchronization
Step 1: Check Synchronization Status
`
SLOS → Multi-Site → Sync → Status Check
`
Synchronization Report:
`json
{
“sync_enabled”: true,
“last_sync”: “2024-12-31T10:00:00Z”,
“syncmethod”: “realtime”,
“sitesinsync”: 4,
“sitesoutof_sync”: 1,
“sync_issues”: [
{
“site_id”: 3,
“issue”: “syncqueuebacklog”,
“records_pending”: 150,
“lastsuccessfulsync”: “2024-12-30T15:30:00Z”
}
],
“performance_metrics”: {
“averagesynctime”: “0.5s”,
“syncsuccessrate”: “98%”,
“queue_size”: 25
}
}
`
Step 2: Fix Synchronization Problems
`
SLOS → Multi-Site → Sync → Problem Resolution
`
Sync Issue Resolution:
`json
{
“resolution_steps”: [
{
“issue”: “syncqueuebacklog”,
“action”: “clearsyncqueue”,
“status”: “in_progress”,
“estimatedcompletion”: “2minutes”
},
{
“issue”: “realtimesync_failures”,
“action”: “switchtobatch_sync”,
“status”: “pending”,
“fallback_available”: true
},
{
“issue”: “crosssiteuser_matching”,
“action”: “implementuserid_mapping”,
“status”: “pending”,
“complexity”: “high”
}
],
“sync_configuration”: {
“sync_method”: “batch”,
“batch_size”: 100,
“sync_interval”: 300,
“errorretrylimit”: 3,
“backoff_multiplier”: 2
}
}
`
Step 3: Implement User ID Mapping
`php
// Cross-site user ID mapping
function mapCrossSiteUserIds($sourceSiteId, $targetSiteId, $userId) {
global $wpdb;
// Check if user exists on target site
$targetUserId = $wpdb->get_var($wpdb->prepare(
“SELECT userid FROM {$wpdb->baseprefix}{$targetSiteId}_users WHERE ID = %d”,
$userId
));
if (!$targetUserId) {
// User doesn’t exist on target site, create mapping record
$wpdb->insert(
“{$wpdb->baseprefix}slosuser_mapping”,
[
‘sourcesiteid’ => $sourceSiteId,
‘targetsiteid’ => $targetSiteId,
‘sourceuserid’ => $userId,
‘mapping_status’ => ‘pending’,
‘createdat’ => currenttime(‘mysql’)
]
);
return false;
}
// Create or update mapping
$wpdb->replace(
“{$wpdb->baseprefix}slosuser_mapping”,
[
‘sourcesiteid’ => $sourceSiteId,
‘targetsiteid’ => $targetSiteId,
‘sourceuserid’ => $userId,
‘targetuserid’ => $targetUserId,
‘mapping_status’ => ‘active’,
‘updatedat’ => currenttime(‘mysql’)
]
);
return $targetUserId;
}
`
Network Administration Challenges
Step 1: Set Up Network Admin Access
`
SLOS → Multi-Site → Admin → Access Setup
`
Network Admin Configuration:
`json
{
“networkadminusers”: [
{
“user_id”: 1,
“username”: “superadmin”,
“sites_managed”: “all”,
“permissions”: [“full_access”]
}
],
“adminmenulocation”: “network_admin”,
“bulkoperationsenabled”: true,
“sitespecificadmin_override”: false,
“audit_logging”: true
}
`
Step 2: Configure Bulk Operations
`
SLOS → Multi-Site → Admin → Bulk Operations
`
Bulk Operation Settings:
`json
{
“available_operations”: [
“updateallsites”,
“syncconsentsettings”,
“bulkexportdata”,
“massconsentreset”,
“networkwidebackup”
],
“operation_queue”: [
{
“operation”: “updateallsites”,
“target_sites”: “all”,
“status”: “pending”,
“scheduled_time”: “2024-12-31T11:00:00Z”
}
],
“progress_tracking”: true,
“rollback_capability”: true
}
`
Step 3: Implement Audit Logging
`php
// Network-wide audit logging
function logNetworkAction($action, $details, $siteId = null) {
global $wpdb;
$logEntry = [
‘timestamp’ => current_time(‘mysql’),
‘userid’ => getcurrentuserid(),
‘action’ => $action,
‘details’ => json_encode($details),
‘siteid’ => $siteId ?: getcurrentblogid(),
‘ipaddress’ => $SERVER[‘REMOTE_ADDR’] ?? null,
‘useragent’ => $SERVER[‘HTTPUSERAGENT’] ?? null
];
$wpdb->insert(“{$wpdb->baseprefix}slosnetworkauditlog”, $logEntry);
// Check for suspicious activity
checkForSuspiciousActivity($logEntry);
}
function checkForSuspiciousActivity($logEntry) {
// Implement suspicious activity detection
$suspiciousPatterns = [
‘massdatadeletion’ => $logEntry[‘action’] === ‘bulkdelete’ && $logEntry[‘details’][‘recordcount’] > 1000,
‘unauthorizedaccess’ => !currentusercan(‘managenetwork’),
‘rapidsettingchanges’ => // Check for rapid changes across multiple sites
];
foreach ($suspiciousPatterns as $pattern => $condition) {
if ($condition) {
triggerNetworkAlert($pattern, $logEntry);
}
}
}
`
Performance Issues in Multi-Site
Step 1: Analyze Network Performance
`
SLOS → Multi-Site → Performance → Network Analysis
`
Network Performance Report:
`json
{
“total_sites”: 5,
“averageresponsetime”: “1.2s”,
“slowest_site”: {
“site_id”: 3,
“response_time”: “3.5s”,
“issue”: “largeconsentdatabase”
},
“database_performance”: {
“sharedtablequeries”: “fast”,
“crosssitejoins”: “slow”,
“recommendedoptimization”: “addsite_indexes”
},
“caching_efficiency”: {
“cachehitrate”: “75%”,
“cache_misses”: 1250,
“recommendedimprovement”: “implementnetwork_cache”
}
}
`
Step 2: Optimize Multi-Site Performance
`sql
— Add performance indexes for multi-site
CREATE INDEX idxsiteconsenttimestamp ON wpslosconsentlog (siteid, consenttimestamp);
CREATE INDEX idxsiteuserconsent ON wpslosconsentlog (siteid, userid, consent_timestamp DESC);
CREATE INDEX idxsiteip ON wpslosconsentlog (siteid, ip_address);
— Optimize shared table queries
ALTER TABLE wpslosconsent_log
ADD PARTITION BY HASH(site_id) PARTITIONS 10;
— Add composite indexes for common queries
CREATE INDEX idxsitecategorytimestamp ON wpslosconsentlog
(siteid, consentcategories(50), consent_timestamp);
`
Step 3: Implement Network Caching
`php
// Network-wide caching strategy
class NetworkCacheManager {
private $cacheGroup = ‘slos_network’;
public function getNetworkData($key, $siteId = null) {
$cacheKey = $siteId ? “site{$siteId}{$key}” : “network_{$key}”;
return wpcacheget($cacheKey, $this->cacheGroup);
}
public function setNetworkData($key, $data, $siteId = null, $expiration = 300) {
$cacheKey = $siteId ? “site{$siteId}{$key}” : “network_{$key}”;
wpcacheset($cacheKey, $data, $this->cacheGroup, $expiration);
// Also cache in network context for cross-site access
if ($siteId) {
$networkKey = “network_{$key}”;
$networkData = $this->getNetworkData($key) ?: [];
$networkData[$siteId] = $data;
wpcacheset($networkKey, $networkData, $this->cacheGroup, $expiration);
}
}
public function clearNetworkCache($key = null, $siteId = null) {
if ($key && $siteId) {
wpcachedelete(“site{$siteId}{$key}”, $this->cacheGroup);
} elseif ($key) {
// Clear from all sites
$sites = get_sites();
foreach ($sites as $site) {
wpcachedelete(“site{$site->blogid}_{$key}”, $this->cacheGroup);
}
wpcachedelete(“network_{$key}”, $this->cacheGroup);
} else {
wpcacheflush_group($this->cacheGroup);
}
}
}
`
Backup and Recovery for Multi-Site
Step 1: Configure Network Backups
`
SLOS → Multi-Site → Backup → Network Configuration
`
Network Backup Strategy:
`json
{
“backupscope”: “networkwide”,
“backup_frequency”: “daily”,
“backup_components”: [
“shared_tables”,
“sitespecifictables”,
“plugin_settings”,
“uploaded_files”
],
“retention_policy”: {
“daily_backups”: 7,
“weekly_backups”: 4,
“monthly_backups”: 12
},
“storage_locations”: [
“local_server”,
“remote_storage”,
“cloud_backup”
]
}
`
Step 2: Implement Network Recovery
`
SLOS → Multi-Site → Recovery → Network Recovery
`
Network Recovery Procedures:
`json
{
“recovery_scenarios”: [
{
“scenario”: “sharedtablecorruption”,
“recoverymethod”: “tablerestore”,
“impact”: “allsitesaffected”,
“downtimeexpected”: “30minutes”
},
{
“scenario”: “singlesitedata_loss”,
“recoverymethod”: “sitespecific_restore”,
“impact”: “onesiteaffected”,
“downtimeexpected”: “5minutes”
},
{
“scenario”: “completenetworkfailure”,
“recoverymethod”: “fullnetwork_restore”,
“impact”: “allsitesaffected”,
“downtimeexpected”: “2hours”
}
],
“recovery_testing”: {
“last_test”: “2024-12-15T10:00:00Z”,
“test_results”: “passed”,
“recommendations”: “test_monthly”
}
}
`
Support Resources
Documentation
- Multi-Site Setup Guide
- Network Administration
- Cross-Site Synchronization
- Multi-site specialists
- Network architecture consultation
- Performance optimization services
- Emergency recovery team
Help
Share this article
Still need help?
Our support team is ready to assist you with personalized guidance for your workspace.