Global Admin

A Deeper Dive into Multinetwork Organization

A presentation by @felixarntz

What is Multinetwork?

  • multiple multisites in one setup
  • i.e. multiple networks
  • i.e. multisite = a single network

Multinetwork Use Cases

Separate sites based on their functionality.

Multinetwork Use Cases

Complex hierarchies with separate ownerships.

Multinetwork Use Cases

Very custom requirements for managing large environments.

Regular Setup

Database Schema

  • wp_commentmeta
  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_termmeta
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy
  • wp_usermeta
  • wp_users

Multisite Setup (First Try)

The above is incomplete!

Database Schema

Sites

  • wp_commentmeta
  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_termmeta
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy
  • wp_2_commentmeta
  • wp_2_comments
  • wp_2_links
  • wp_2_options
  • wp_2_postmeta
  • wp_2_posts
  • wp_2_termmeta
  • wp_2_terms
  • wp_2_term_relationships
  • wp_2_term_taxonomy

Database Schema

Network

  • wp_blogs
  • wp_blog_versions
  • wp_registration_log
  • wp_signups
  • wp_sitemeta
  • wp_site
  • wp_usermeta
  • wp_users

You can have multiple networks! 😲

Multinetwork Setup

On the database level, all multisite tables are actually global.

Multisite Setup (Second Try)

WordPress Core Support for Multinetwork

Available Support

  • database tables wp_site and wp_sitemeta
  • WP_Network and WP_Network_Query classes
  • Network administration panels per network

WordPress Core Support for Multinetwork

Lacking Support

  • CUD API for networks (the R is supported)
  • CRUD UI for networks
  • user roles and capabilities that go beyond a single network
  • association between users and the networks they are part of
  • switching context to another network
  • link connections between network administration panels
  • several more trivial things here or there...

So how do I actually get to use Multinetwork?

Use WP Multi Network, the established way to expose basic multi network functionality with a UI (github.com/stuttter/wp-multi-network)

or build your own custom solution (example: github.com/washingtonstateuniversity/WSUWP-Plugin-Multiple-Networks).

Problem: Not every network administrator should be able to create new networks.

Goal: Handle this functionality in global scope.

Dealing with global scope data

Two Alternatives:

  • Use main network as global scope layer (easy solution, but conceptual hack).
  • Implement missing global functionality (clean solution, but technical hack).

Using the main network for global scope functionality

github.com/washingtonstateuniversity/WSUWP-Plugin-Multiple-Networks
Disclaimer: Most of the plugin is reusable functionality, but a few parts are still specific to the WSU environment.

  • global data stored as network settings (in wp_sitemeta table)
  • global admins are network administrators on the main network
  • global UI added as menu/submenu pages in the network administration panel
  • misuses the network administration panel, but ties in with existing WordPress functionality

Implementing actual global scope functionality

github.com/felixarntz/wp-global-options
github.com/felixarntz/wp-global-admin
(they both integrate with github.com/stuttter/wp-multi-network)

  • global data stored specifically as global settings (in wp_global_options table)
  • global admins are stored as a global setting
  • global UI available in entirely new global administration panel
  • behaves like existing WordPress functionality, but several ugly hacks required to make custom administration panel work

Problem: Network administrators can see all users,
even those that are not part of their network.

Goal: Store associations between users and their networks
so that they can easily be retrieved.

Store associations between users and networks

Two Alternatives:

  • Store network IDs as user metadata (simple solution).
  • Store an empty capabilities array under capability keys for each network as user metadata (somewhat similar, but future-proof).

Store associations between users and networks

github.com/felixarntz/wp-network-roles
implements network-wide user roles and thus also stores user-network associations.
It integrates well with the aforementioned global scope plugins.

github.com/washingtonstateuniversity/WSUWP-Plugin-Multiple-Networks
includes user-network association as well, storing an empty array under a network's capability key.

Disclaimer:
All plugins mentioned here integrate deeply into WordPress core and, although they are regularly maintained, they should be used with care.
They're already being used in specific production environments, but it is generally recommended to first experiment on development sites for quite a bit.

The Future of Multinetwork and WordPress Core

  • WordPress core will never add a UI for multiple networks. This should remain plugin territory due to vast differences in how the feature is used today.
  • A very basic and unopinionated CRUD API will be introduced for networks, including REST API support (likely in late 2018 or 2019).
  • Hooks will be introduced and bugs will be fixed to improve multinetwork support where the respective plugins would wanna integrate.

Have a larger project to manage? Try Multinetwork today and help us out!

Thank you!

Felix Arntz

Plugin Developer / Core Committer / Freelancer