Create sites within Multisite when a purchase is made in WooCommerce

I'm using Multisite and WooCommerce Subscriptions, the end goal is to have a private site created for the end user that makes a purchase.

Ideally I would like the end user John Doe to make a purchase and create an account on example.com so that once the purchase is completed example.com/johndoe is created and only the user John Doe has access to it.

Can anyone point me in the right direction?

I'm using the New Blog Template and have created a small plugin to change the user from an admin to a subscriber so they can't make changes to the backend.

  • Michelle Shull
    • DEV MAN’s Apprentice

    Hi, Daniel!

    I'm not familiar with WooCommerce Subscriptions, but I think we can help out here with a plugin of our own, ProSites. ProSites let's you monetize site creation in a multisite. Check out the guide here: https://premium.wpmudev.org/project/pro-sites/

    We just did a major update that lets users register an account and create a ProSite in a single step.

    ProSites ties in great with New Blog Templates, the template chooser will show up on the ProSite purchase page.

    The only issue I see is switching the user to a subscriber, with that user role, the only permissions the site owners will have is to comment on their sites, they won't be able to create posts or pages unless you're also using a front-end publishing tool. You may want to look at using Contributor instead, they can't make design/functionality changes like switching themes, adding widgets, or adjusting plugin settings, but they can create posts. (Contributors can't publish or embed videos/tweets, however, that requires Author privileges.)

    Would ProSites work for you here, or is integration with Subscriptions critical to your project?

    Thanks!

  • Dan Maby
    • Site Builder, Child of Zeus

    Hey Michelle
    Thanks for the quick response. Unfortunately Pro Sites doesn't fit our requirements, I've looked at it but our subscription model has a complex workflow. So we need to stick with woo for now.

    Regarding the subscriber user level; the end user will only be able to submit forms via Gravity Forms and these will be limited to logged in users only. This is the reason I want to limit the site to logged in users as the end user making the purchase will be the only user on the site (excluding super admins).

    Thanks again,
    Dan

  • Jude
    • DEV MAN

    Hey Daniel Marby

    You'll need the developer version of Gravity forms for this, once the form is submitted you can use their API to read values.

    https://www.gravityhelp.com/documentation/article/api-functions/#get_form

    THEN you can manually create a bog using what you read in using this function.

    https://codex.wordpress.org/WPMU_Functions/wpmu_create_blog

    FINALLY template it using NBT template it

    function set_blog_defaults( $blog_id, $user_id, $_passed_domain=false, $_passed_path=false, $_passed_site_id=false, $_passed_meta=false ) {

    Hope that helps
    Jude

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.