How to set the pro site level programatically

I have customized pro site level selection in my front page. While selecting one of this pro selection, user will redirect to word press create site page [I do not want to provide another pro site selection in sign up page. so I hide that in sign up page]. There I wan to create the site based on the pro site level value already selected in the front page. I am sending [POST] following values while the user click on sign up button. But still my new site is created as non-pro site.
extend_level = 2, level = 2 , period = 1

What are the pro site parameters I am suppose to send while create a site from WP sign-up page [remember, there is no pro site selection in sign-up page] ?

  • Ash

    Hello @devassy

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    I am not sure if that can be done easily. I am tagging an available developer from second level support line in this thread for his valuable opinion on this issue. Please note that, developer response might be slower than usual staff response, so we appreciate your patience on this.


  • Jose

    Hi there devassy,

    Hope you are doing great.

    Unfortunately, it is not so simple. The workflow is bit more complex because we have the payment gateways in the middle. I can give you some pointers on how to approach this customization though.

    I'm not quite sure how would you deal with payments in your case. If your levels are free, then the workflow might be simpler.

    You need to keep record of the level/period selected in the front page, and then hook into 'wpmu_new_blog' action in order to assign the selected level/period once the site is created.

    The programatically way to assign a level is by using the 'extend' method.

    This is a draft of what you would need to add. (it will need more work, of course):

    add_action( 'wpmu_new_blog',  'assign_level', 99, 1  );
    function assign_level( $blog_id ) {
       global $psts;
       $extend = xxxx;//Duration of the subscription in seconds. You should get the period selected in the front page and convert it to seconds.
       $gateway = 'Free'; //The name of the payment gateway.
       $level = 1;//The level id selected in the front page.
       $amount = false;//If paid, the cost of the subscription.
       $psts->extend( $blog_id, $extend, $gateway, $level, $amount );
       $psts->email_notification( $blog_id, 'success' );
       $psts->record_stat( $blog_id, 'signup' );
       update_blog_option( $blog_id, 'psts_waiting_step', 0 );

    Hope this helps.

    I'll be glad to help if you have further questions.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.