The populate_network_meta WordPress PHP filter allows you to modify the metadata of a network during its creation process.
Usage
add_filter('populate_network_meta', 'your_custom_function', 10, 2); function your_custom_function($sitemeta, $network_id) { // your custom code here return $sitemeta; }
Parameters
$sitemeta
: array – Associative array of network meta keys and values to be inserted.$network_id
: int – ID of the network to populate.
More information
See WordPress Developer Resources: populate_network_meta
Examples
Set a custom value for a network
Set a custom value ‘custom_value’ with the key ‘custom_key’ for a newly created network.
add_filter('populate_network_meta', 'set_custom_value', 10, 2); function set_custom_value($sitemeta, $network_id) { $sitemeta['custom_key'] = 'custom_value'; return $sitemeta; }
Set network language
Set the language of a newly created network to Spanish.
add_filter('populate_network_meta', 'set_network_language', 10, 2); function set_network_language($sitemeta, $network_id) { $sitemeta['WPLANG'] = 'es_ES'; return $sitemeta; }
Enable default theme
Enable a default theme for a newly created network.
add_filter('populate_network_meta', 'enable_default_theme', 10, 2); function enable_default_theme($sitemeta, $network_id) { $sitemeta['default_theme'] = 'your_theme_slug'; return $sitemeta; }
Disable comments
Disable comments for a newly created network by default.
add_filter('populate_network_meta', 'disable_comments', 10, 2); function disable_comments($sitemeta, $network_id) { $sitemeta['default_comment_status'] = 'closed'; return $sitemeta; }
Set custom upload limit
Set a custom upload limit of 20MB for a newly created network.
add_filter('populate_network_meta', 'set_upload_limit', 10, 2); function set_upload_limit($sitemeta, $network_id) { $sitemeta['fileupload_maxk'] = 20480; return $sitemeta; }