The populate_network() WordPress PHP function populates the network settings for a WordPress multisite installation.
Usage
populate_network( $network_id, $domain, $email, $site_name, $path, $subdomain_install );
Parameters
$network_id
(int) Optional: ID of the network to populate. Default: 1$domain
(string) Optional: The domain name for the network. Example: “example.com”. Default: ”$email
(string) Optional: Email address for the network administrator. Default: ”$site_name
(string) Optional: The name of the network. Default: ”$path
(string) Optional: The path to append to the network’s domain name. Default: ‘/’$subdomain_install
(bool) Optional: Whether the network is a subdomain installation or a subdirectory installation. Default: false (subdirectory installation)
More information
See WordPress Developer Resources: populate_network()
Examples
Basic example
Populate network settings for a subdirectory installation:
populate_network( 1, 'example.com', '[email protected]', 'My Network', '/', false );
Subdomain installation
Populate network settings for a subdomain installation:
populate_network( 1, 'example.com', '[email protected]', 'My Network', '/', true );
Custom network ID
Populate network settings with a custom network ID:
populate_network( 2, 'example.com', '[email protected]', 'My Network', '/', false );
Custom path
Populate network settings with a custom path:
populate_network( 1, 'example.com', '[email protected]', 'My Network', '/custompath/', false );
Different site name
Populate network settings with a different site name:
populate_network( 1, 'example.com', '[email protected]', 'Another Network', '/', false );