wp_insert_site

SummerySummery

Inserts a new site into the database.

Syntax

wp_insert_site( array $data )

ParametersParameters

$data

(array) (Required) Data for the new site that should be inserted.

  • 'domain'
    (string) Site domain. Default empty string.
  • 'path'
    (string) Site path. Default '/'.
  • 'network_id'
    (int) The site's network ID. Default is the current network ID.
  • 'registered'
    (string) When the site was registered, in SQL datetime format. Default is the current time.
  • 'last_updated'
    (string) When the site was last updated, in SQL datetime format. Default is the value of $registered.
  • 'public'
    (int) Whether the site is public. Default 1.
  • 'archived'
    (int) Whether the site is archived. Default 0.
  • 'mature'
    (int) Whether the site is mature. Default 0.
  • 'spam'
    (int) Whether the site is spam. Default 0.
  • 'deleted'
    (int) Whether the site is deleted. Default 0.
  • 'lang_id'
    (int) The site's language ID. Currently unused. Default 0.
  • 'user_id'
    (int) User ID for the site administrator. Passed to the wp_initialize_site hook.
  • 'title'
    (string) Site title. Default is 'Site %d' where %d is the site ID. Passed to the wp_initialize_site hook.
  • 'options'
    (array) Custom option $key => $value pairs to use. Default empty array. Passed to the wp_initialize_site hook.
  • 'meta'
    (array) Custom site metadata $key => $value pairs to use. Default empty array. Passed to the wp_initialize_site hook.

ReturnReturn

(int|WP_Error) The new site's ID on success, or error object on failure.

SourceSource

File: wp-includes/ms-site.php


			

ChangelogChangelog

Changelog
Version Description
5.1.0 Introduced.
Scroll to Top