Starter database on a new site created by Pro Sites?

I can see how to set up Pro Sites to set up a new user site. However, as part of the new site, I would like to provide initial starter data like help files, suggested resources, etc. pre populated in the database as custom post types. Is there a way to use New Blog Template with Pro Sites? If not what would be the best way to accomplish this?

It seems it would be possible to use a custom plugin to do this but with the Multisite Content Copy technology, New Blog Template, Site Cloner, etc. it seems that there could be an easier solution from WPMUDEV.

Any ideas?

  • Michelle Shull

    Hey there, Tom!

    Integrating ProSites and New Blog Templates is a popular feature request, and I agree it would make the entire Pro Site process so much easier to manage. As of right now, however, it's not yet been added.

    The other plugins you mention, Content Copier, NBT, Cloner, etc, all do slightly different things than what you're aiming for, but you can do a bit of a workaround via Multisite Content Copier, as long as you limit your content to either pages or posts. To do this, you'd create a new site (just to keep things as simple as possible), add the content you want all your sites to have, then use Content Copier to export only the data you just created.

    Now, once the new Pro Site is created, you can import the content you copied and it should work just as expected.

    Hope this helps, and welcome to WPMU DEV! We're so glad you joined us. :slight_smile:

  • Tom

    Thank you Michelle.

    Is there any hooks or other ways to execute some code when the user has just activated with Pro Sites? I am hoping to fully provision the user at sign up since I am really activating an app and not a site really so that the user doesn't have to wait for a manual action before the working application (depends on data in the database) is available.

    I could populate the database on the new site with code but need to know when a sign up has occurred and ideally at what level.


  • aristath

    Hello there @Tom, I hope you're well today!

    You can detect the level of a pro-site using this code:

    global $wpdb;
    $blog_id = $wpdb->blogid;
    $sql = "SELECT level FROM {$wpdb->base_prefix}pro_sites WHERE blog_ID = '$blog_id'";
    $level = $wpdb->get_var($sql);

    As for an action that gets run during the site creation I didn't find any in the plugin, apparently this is handled by WordPress core.

    However you could use an option like this:

    $creation_code_run = get_option( 'custom_code_run', false );
    if ( ! $creation_code_run ) {
    	// update the option to 1
    	update_option( 'custom_code_run', true );

    This way the custom code will not be executed during the site creation itself, but it should be run on the first visit to the dashboard or the frontend of the site.
    We basically save an option in the db that's boolean and checks if the code has been run or not. If it has not already been executed it will be, otherwise it will be skipped. :slight_smile:

    I hope that helps!


  • Tom

    I wanted to report back as I found a way to solve the problem (at least for me) of including an initial database another way. You can set up the initial settings and database with the New Blog Template plugin. If you set the blog id of the site you want to be the reference site for new customers and set it to be default, it will provision everything on new signups. I think this will work ok since the starter database that I have will be the same for all users even for the prosites free level that I am planning. I don't think this would work if you needed different databases based on prosites level. My next step will be to make some plugins that are enabled based on prosites level and control available application features. I just got this working so I could run into surprises but thought I would report back.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.