wp_insert_site example


        array_intersect_key( $optionsarray_flip( $allowed_data_fields ) )
    );

    // Data to pass to wp_initialize_site().     $site_initialization_data = array(
        'title'   => $title,
        'user_id' => $user_id,
        'options' => array_diff_key( $optionsarray_flip( $allowed_data_fields ) ),
    );

    $blog_id = wp_insert_site( array_merge( $site_data$site_initialization_data ) );

    if ( is_wp_error( $blog_id ) ) {
        return $blog_id;
    }

    wp_cache_set_sites_last_changed();

    return $blog_id;
}

/** * Notifies the network admin that a new site has been activated. * * Filter {@see 'newblog_notify_siteadmin'} to change the content of * the notification email. * * @since MU (3.0.0) * @since 5.1.0 $blog_id now supports input from the {@see 'wp_initialize_site'} action. * * @param WP_Site|int $blog_id The new site's object or ID. * @param string $deprecated Not used. * @return bool */

function insert_blog($domain$path$site_id) {
    _deprecated_function( __FUNCTION__, '5.1.0', 'wp_insert_site()' );

    $data = array(
        'domain'  => $domain,
        'path'    => $path,
        'site_id' => $site_id,
    );

    $site_id = wp_insert_site( $data );
    if ( is_wp_error( $site_id ) ) {
        return false;
    }

    clean_blog_cache( $site_id );

    return $site_id;
}

/** * Install an empty blog. * * Creates the new blog tables and options. If calling this function * directly, be sure to use switch_to_blog() first, so that $wpdb * points to the new blog. * * @since MU (3.0.0) * @deprecated 5.1.0 * * @global wpdb $wpdb WordPress database abstraction object. * @global WP_Roles $wp_roles WordPress role management object. * * @param int $blog_id The value returned by wp_insert_site(). * @param string $blog_title The title of the new site. */
Home | Imprint | This part of the site doesn't use cookies.