wpmu_create_blog example

/** * Fires after a new user has been created via the network site-new.php page. * * @since 4.4.0 * * @param int $user_id ID of the newly created user. */
        do_action( 'network_site_new_created_user', $user_id );
    }

    $wpdb->hide_errors();
    $id = wpmu_create_blog( $newdomain$path$title$user_id$metaget_current_network_id() );
    $wpdb->show_errors();

    if ( ! is_wp_error( $id ) ) {
        if ( ! is_super_admin( $user_id ) && ! get_user_option( 'primary_blog', $user_id ) ) {
            update_user_option( $user_id, 'primary_blog', $id, true );
        }

        wpmu_new_site_admin_notification( $id$user_id );
        wpmu_welcome_notification( $id$user_id$password$title, array( 'public' => 1 ) );
        wp_redirect(
            add_query_arg(
                

    $meta = apply_filters( 'add_signup_meta', $meta_defaults );

    $blog_id = wpmu_create_blog( $domain$path$blog_title$current_user->ID, $metaget_current_network_id() );

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

    confirm_another_blog_signup( $domain$path$blog_title$current_user->user_login, $current_user->user_email, $meta$blog_id );
    return true;
}

/** * Shows a message confirming that the new site has been created. * * @since MU (3.0.0) * @since 4.4.0 Added the `$blog_id` parameter. * * @param string $domain The domain URL. * @param string $path The site root path. * @param string $blog_title The site title. * @param string $user_name The username. * @param string $user_email The user's email address. * @param array $meta Any additional meta from the {@see 'add_signup_meta'} filter in validate_blog_signup(). * @param int $blog_id The site ID. */

        do_action( 'wpmu_activate_user', $user_id$password$meta );

        return array(
            'user_id'  => $user_id,
            'password' => $password,
            'meta'     => $meta,
        );
    }

    $blog_id = wpmu_create_blog( $signup->domain, $signup->path, $signup->title, $user_id$metaget_current_network_id() );

    // TODO: What to do if we create a user but cannot create a blog?     if ( is_wp_error( $blog_id ) ) {
        /* * If blog is taken, that means a previous attempt to activate this blog * failed in between creating the blog and setting the activation flag. * Let's just set the active flag and instruct the user to reset their password. */
        if ( 'blog_taken' === $blog_id->get_error_code() ) {
            $blog_id->add_data( $signup );
            $wpdb->update(
                
Home | Imprint | This part of the site doesn't use cookies.