Managing dozens or hundreds of WordPress Multisite network sites through the admin dashboard is tedious—creating sites manually, adding users one-by-one, updating plugins across all sites, and managing network settings requires hours of repetitive clicking.
WP-CLI transforms WordPress Multisite management with powerful network commands that create sites instantly, bulk manage users, update plugins network-wide, and automate complex operations across hundreds of sites with single commands.
In this guide, you’ll master WordPress Multisite network management with WP-CLI, from basic site creation to advanced bulk operations managing large-scale WordPress networks efficiently.
Why Use WP-CLI for Multisite?
WordPress Multisite dashboard management doesn’t scale when managing more than a handful of sites.
Dashboard Management Limitations
Time-consuming: Creating sites manually takes 5-10 minutes each.
No bulk operations: Must update plugins/themes on each site individually.
Limited automation: Can’t script repetitive network operations.
User management complexity: Adding users across multiple sites is tedious.
No reporting: Can’t generate network-wide statistics easily.
WP-CLI Multisite Advantages
Instant site creation: Create dozens of sites in seconds with scripts.
Network-wide updates: Update plugins/themes across all sites with one command.
Bulk user management: Add/remove users from multiple sites simultaneously.
Complete automation: Script complex network operations and scheduling.
Powerful reporting: Generate comprehensive network statistics instantly.
According to WordPress Multisite best practices, WP-CLI reduces network management time by 80% for networks with 10+ sites.
Multisite Network Commands Overview
Essential WP-CLI commands for Multisite networks.
Basic Network Information
# Check if Multisite is enabled
wp core is-installed --network
# List all sites in network
wp site list
# Get network details
wp site list --format=table --fields=blog_id,url,registered
# Count total sites
wp site list --format=count
# List sites with specific criteria
wp site list --field=url --archived=0 --deleted=0Network Site Management
# Create new site
wp site create --slug=newsite --title="New Site"
# Create site with custom email
wp site create \
--slug=department \
--title="Department Site" \
--email=admin@department.com
# Delete site
wp site delete 5 --yes
# Archive site
wp site archive 5
# Unarchive site
wp site unarchive 5
# Mark site as spam
wp site spam 5
# Empty (delete all content but keep site)
wp site empty 5 --yesLearn about WordPress Multisite architecture.
Bulk Site Creation and Provisioning
Automate creating multiple sites programmatically.
Batch Site Creation Script
#!/bin/bash
# create-sites-batch.sh - Create multiple sites from CSV
SITES_CSV="sites.csv"
if [ ! -f "$SITES_CSV" ]; then
echo "ERROR: $SITES_CSV not found"
exit 1
fi
echo "Creating sites from $SITES_CSV"
# Skip header row, read CSV
tail -n +2 "$SITES_CSV" | while IFS=, read -r SLUG TITLE EMAIL; do
echo "Creating site: $SLUG"
# Check if site already exists
if wp site list --field=url | grep -q "/$SLUG"; then
echo "⊘ Site $SLUG already exists, skipping"
continue
fi
# Create site
SITE_ID=$(wp site create \
--slug="$SLUG" \
--title="$TITLE" \
--email="$EMAIL" \
--porcelain)
if [ $? -eq 0 ]; then
echo "✓ Created site: $SLUG (ID: $SITE_ID)"
else
echo "✗ Failed to create site: $SLUG"
fi
done
echo "Batch site creation complete"Sites CSV Template
slug,title,email
sales,Sales Department,sales@example.com
marketing,Marketing Department,marketing@example.com
support,Support Department,support@example.com
engineering,Engineering Department,engineering@example.com
Automated Site Provisioning
#!/bin/bash
# provision-new-site.sh - Complete site setup
SLUG="$1"
TITLE="$2"
ADMIN_EMAIL="$3"
if [ -z "$SLUG" ] || [ -z "$TITLE" ] || [ -z "$ADMIN_EMAIL" ]; then
echo "Usage: $0 <slug> <title> <admin_email>"
exit 1
fi
echo "Provisioning new site: $SLUG"
# Create site
SITE_ID=$(wp site create \
--slug="$SLUG" \
--title="$TITLE" \
--email="$ADMIN_EMAIL" \
--porcelain)
echo "✓ Site created (ID: $SITE_ID)"
# Switch to new site context
export WP_CLI_STRICT_ARGS_MODE=1
# Install and activate plugins
echo "Installing plugins..."
wp plugin install --activate \
--url="$SLUG" \
wordpress-seo \
contact-form-7 \
wordfence
# Install theme
echo "Installing theme..."
wp theme install twentytwentyfour --activate --url="$SLUG"
# Create default pages
echo "Creating default pages..."
wp post create \
--url="$SLUG" \
--post_type=page \
--post_title='Home' \
--post_status=publish \
--post_content='Welcome to our site'
wp post create \
--url="$SLUG" \
--post_type=page \
--post_title='About' \
--post_status=publish
wp post create \
--url="$SLUG" \
--post_type=page \
--post_title='Contact' \
--post_status=publish
# Set front page
HOME_ID=$(wp post list --url="$SLUG" --post_type=page --name=home --field=ID)
wp option update --url="$SLUG" page_on_front "$HOME_ID"
wp option update --url="$SLUG" show_on_front page
# Configure settings
wp option update --url="$SLUG" blogdescription "Powered by WordPress Multisite"
wp option update --url="$SLUG" permalink_structure '/%postname%/'
echo "✓ Site provisioning complete: $SLUG"Network-Wide Plugin and Theme Management
Manage plugins and themes across all sites.
Network-Wide Plugin Operations
# Install plugin network-wide
wp plugin install akismet --network
# Activate plugin for entire network
wp plugin activate akismet --network
# Deactivate network-wide
wp plugin deactivate akismet --network
# Update all plugins across all sites
for url in $(wp site list --field=url); do
echo "Updating plugins for: $url"
wp plugin update --all --url="$url"
done
# Check plugin status across network
wp site list --field=url | while read site_url; do
echo "=== Plugins on $site_url ==="
wp plugin list --url="$site_url" --status=active --format=table
doneBulk Theme Management
#!/bin/bash
# manage-themes-network.sh
ACTION="${1:-list}" # list, install, activate, delete
case "$ACTION" in
list)
echo "Themes across network:"
wp site list --field=url | while read url; do
echo "Site: $url"
wp theme list --url="$url" --status=active --fields=name,version
echo ""
done
;;
install)
THEME="$2"
echo "Installing $THEME on all sites..."
for url in $(wp site list --field=url); do
wp theme install "$THEME" --url="$url"
done
;;
activate)
THEME="$2"
echo "Activating $THEME on all sites..."
for url in $(wp site list --field=url); do
wp theme activate "$THEME" --url="$url"
done
;;
delete)
THEME="$2"
echo "Deleting $THEME from all sites..."
for url in $(wp site list --field=url); do
wp theme delete "$THEME" --url="$url"
done
;;
*)
echo "Usage: $0 {list|install|activate|delete} [theme-name]"
exit 1
;;
esacLearn about Multisite plugin management.
User Management Across Network
Manage users and roles across multiple sites.
Add Users to Multiple Sites
#!/bin/bash
# add-user-to-sites.sh - Add user to multiple sites
USERNAME="$1"
ROLE="${2:-subscriber}"
if [ -z "$USERNAME" ]; then
echo "Usage: $0 <username> [role]"
exit 1
fi
# Check if user exists
if ! wp user get "$USERNAME" &>/dev/null; then
echo "ERROR: User $USERNAME does not exist"
exit 1
fi
echo "Adding $USERNAME as $ROLE to all sites..."
# Get all site IDs
SITES=$(wp site list --field=blog_id)
for SITE_ID in $SITES; do
SITE_URL=$(wp site list --blog_id="$SITE_ID" --field=url)
# Add user to site
wp user set-role "$USERNAME" "$ROLE" --url="$SITE_URL"
if [ $? -eq 0 ]; then
echo "✓ Added to: $SITE_URL"
else
echo "✗ Failed: $SITE_URL"
fi
done
echo "User addition complete"Bulk User Role Management
#!/bin/bash
# manage-user-roles.sh
# List all users across network
network_user_report() {
echo "Network User Report"
echo "==================="
wp site list --field=url | while read url; do
echo ""
echo "Site: $url"
wp user list --url="$url" --format=table --fields=user_login,roles,user_email
done
}
# Remove user from all sites
remove_user_network() {
local username="$1"
echo "Removing $username from all sites..."
for url in $(wp site list --field=url); do
if wp user list --url="$url" --field=user_login | grep -q "^$usernamequot;; then
wp user remove-role "$username" --url="$url"
echo "✓ Removed from: $url"
fi
done
}
# Promote user to admin on all sites
promote_to_admin_network() {
local username="$1"
echo "Promoting $username to administrator on all sites..."
for url in $(wp site list --field=url); do
wp user set-role "$username" administrator --url="$url"
echo "✓ Promoted on: $url"
done
}
# Main script
case "$1" in
report)
network_user_report
;;
remove)
remove_user_network "$2"
;;
promote)
promote_to_admin_network "$2"
;;
*)
echo "Usage: $0 {report|remove|promote} [username]"
exit 1
;;
esacSuper Admin Management
# Grant super admin privileges
wp super-admin add username
# Remove super admin privileges
wp super-admin remove username
# List all super admins
wp super-admin list
# Check if user is super admin
wp user get username --field=caps | grep -q "super_admin"Network Statistics and Reporting
Generate comprehensive network reports.
Network Health Report
#!/bin/bash
# network-health-report.sh
REPORT_FILE="/tmp/multisite-health-$(date +%Y%m%d).txt"
{
echo "WordPress Multisite Network Health Report"
echo "=========================================="
echo "Generated: $(date)"
echo ""
# Network overview
echo "Network Overview"
echo "----------------"
SITE_COUNT=$(wp site list --format=count)
ACTIVE_SITES=$(wp site list --archived=0 --deleted=0 --format=count)
ARCHIVED_SITES=$(wp site list --archived=1 --format=count)
DELETED_SITES=$(wp site list --deleted=1 --format=count)
echo "Total sites: $SITE_COUNT"
echo "Active sites: $ACTIVE_SITES"
echo "Archived sites: $ARCHIVED_SITES"
echo "Deleted sites: $DELETED_SITES"
echo ""
# User statistics
echo "User Statistics"
echo "---------------"
TOTAL_USERS=$(wp user list --format=count)
SUPER_ADMINS=$(wp super-admin list --format=count)
echo "Total users: $TOTAL_USERS"
echo "Super admins: $SUPER_ADMINS"
echo ""
# Plugin status across network
echo "Network Plugin Status"
echo "---------------------"
echo "Network-activated plugins:"
wp plugin list --status=active-network --format=table --fields=name,version
echo ""
# Site details
echo "Site Details"
echo "------------"
wp site list --format=table --fields=blog_id,url,registered,last_updated
echo ""
# Storage usage (if multisite uses subdirectories)
echo "Storage Usage"
echo "-------------"
for site_id in $(wp site list --field=blog_id); do
url=$(wp site list --blog_id="$site_id" --field=url)
uploads_dir="wp-content/uploads/sites/$site_id"
if [ -d "$uploads_dir" ]; then
size=$(du -sh "$uploads_dir" | cut -f1)
echo "$url: $size"
fi
done
} > "$REPORT_FILE"
echo "✓ Report generated: $REPORT_FILE"
# Email report
mail -s "Multisite Network Health Report" admin@example.com < "$REPORT_FILE"Activity Monitoring
#!/bin/bash
# monitor-network-activity.sh
echo "Network Activity Monitor"
echo "========================"
# Recently created sites
echo "Recently Created Sites (last 7 days):"
wp site list --format=table --fields=blog_id,url,registered | \
grep "$(date -d '7 days ago' '+%Y-%m-%d')"
echo ""
# Recently updated sites
echo "Recently Updated Sites:"
wp site list --format=table --fields=blog_id,url,last_updated
echo ""
# New users (last 24 hours)
echo "New Users (last 24 hours):"
wp user list --format=table --fields=user_login,user_email,user_registered | \
grep "$(date '+%Y-%m-%d')"
echo ""
# Plugin update status
echo "Sites Needing Plugin Updates:"
for url in $(wp site list --field=url); do
UPDATES=$(wp plugin list --url="$url" --update=available --format=count)
if [ "$UPDATES" -gt 0 ]; then
echo " $url: $UPDATES plugin updates available"
fi
doneLearn about Multisite network analytics.
Backup and Clone Operations
Backup individual sites or clone across network.
Individual Site Backup
#!/bin/bash
# backup-multisite-site.sh
SITE_ID="$1"
BACKUP_DIR="/backups/multisite"
if [ -z "$SITE_ID" ]; then
echo "Usage: $0 <site_id>"
exit 1
fi
SITE_URL=$(wp site list --blog_id="$SITE_ID" --field=url)
DATE=$(date +%Y%m%d_%H%M%S)
echo "Backing up site: $SITE_URL"
mkdir -p "$BACKUP_DIR"
# Export database for specific site
wp db export "$BACKUP_DIR/site-${SITE_ID}-${DATE}.sql.gz" --url="$SITE_URL"
# Backup uploads directory
if [ -d "wp-content/uploads/sites/$SITE_ID" ]; then
tar -czf "$BACKUP_DIR/uploads-${SITE_ID}-${DATE}.tar.gz" \
"wp-content/uploads/sites/$SITE_ID"
fi
echo "✓ Backup complete: $BACKUP_DIR"Clone Site Within Network
#!/bin/bash
# clone-multisite-site.sh
SOURCE_SITE_ID="$1"
NEW_SLUG="$2"
NEW_TITLE="$3"
if [ -z "$SOURCE_SITE_ID" ] || [ -z "$NEW_SLUG" ]; then
echo "Usage: $0 <source_site_id> <new_slug> <new_title>"
exit 1
fi
SOURCE_URL=$(wp site list --blog_id="$SOURCE_SITE_ID" --field=url)
echo "Cloning site: $SOURCE_URL to /$NEW_SLUG"
# Export source site
TEMP_SQL="/tmp/clone-$SOURCE_SITE_ID.sql"
wp db export "$TEMP_SQL" --url="$SOURCE_URL"
# Create new site
NEW_SITE_ID=$(wp site create \
--slug="$NEW_SLUG" \
--title="$NEW_TITLE" \
--email="admin@example.com" \
--porcelain)
echo "✓ New site created (ID: $NEW_SITE_ID)"
# Import database to new site
# Note: This requires custom SQL modification for multisite table prefixes
echo "Manual step required: Modify SQL dump table prefixes from wp_${SOURCE_SITE_ID}_ to wp_${NEW_SITE_ID}_"
echo "Clone preparation complete"Network Maintenance Automation
Automate routine network maintenance tasks.
Automated Maintenance Script
#!/bin/bash
# multisite-maintenance.sh
LOG_FILE="/var/log/multisite-maintenance.log"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $@" | tee -a "$LOG_FILE"
}
log "=== Multisite Maintenance Started ==="
# Update WordPress core on all sites
log "Updating WordPress core..."
wp core update --network
# Update all plugins across network
log "Updating plugins network-wide..."
for url in $(wp site list --field=url); do
log "Updating plugins on: $url"
wp plugin update --all --url="$url" 2>&1 | tee -a "$LOG_FILE"
done
# Update all themes
log "Updating themes network-wide..."
for url in $(wp site list --field=url); do
log "Updating themes on: $url"
wp theme update --all --url="$url" 2>&1 | tee -a "$LOG_FILE"
done
# Clear caches
log "Clearing caches..."
for url in $(wp site list --field=url); do
wp cache flush --url="$url"
done
# Optimize databases
log "Optimizing databases..."
wp db optimize
# Clean up spam/trash
log "Cleaning up spam and trash..."
for url in $(wp site list --field=url); do
wp post delete $(wp post list --url="$url" --post_status=trash --format=ids) --force
wp comment delete $(wp comment list --url="$url" --status=spam --format=ids) --force
done
log "=== Maintenance Complete ==="Scheduled Network Maintenance
# Add to crontab: crontab -e
# Weekly network maintenance (Sundays at 2 AM)
0 2 * * 0 /usr/local/bin/multisite-maintenance.sh
# Daily network health report
0 8 * * * /usr/local/bin/network-health-report.sh
# Monthly user audit across network
0 9 1 * * /usr/local/bin/network-user-report.sh | mail -s "Monthly Network User Report" admin@example.comNext Steps
You now have comprehensive WordPress Multisite network management capabilities with WP-CLI.
Recommended Learning Path
Week 1: Basic operations
- Create and manage sites
- Understand network commands
- Practice bulk operations
Week 2: User management
- Add users across network
- Manage roles and permissions
- Configure super admins
Week 3: Automation
- Build provisioning scripts
- Automate maintenance tasks
- Create reporting systems
Week 4: Production scaling
- Optimize large networks
- Implement monitoring
- Backup and disaster recovery
Advanced Topics
- Multi-Network WordPress – Networks of networks
- Multisite Performance Optimization – Scale to thousands of sites
- Custom Network Plugins – Build network-specific functionality
Get More Resources
Download Multisite scripts including:
- Site provisioning automation
- Network management tools
- Reporting templates
- Weekly WP-CLI tutorials
- Multisite best practices
- Network scaling strategies
Conclusion
WordPress Multisite network management with WP-CLI transforms tedious manual operations into automated workflows—enabling efficient management of networks with hundreds or thousands of sites.
What we covered:
✅ Essential Multisite network commands
✅ Bulk site creation and provisioning
✅ Network-wide plugin and theme management
✅ User management across multiple sites
✅ Comprehensive network reporting
✅ Automated maintenance workflows
Master these techniques, and you’ll manage large WordPress Multisite networks effortlessly—provisioning sites instantly, automating updates, and monitoring health across entire networks.
Ready for more? Learn Multisite performance optimization or enterprise WordPress architecture.
Questions about WordPress Multisite management? Drop a comment below!
Found this helpful? Share with other network administrators.
