Pro Sites Redirect after successful payment

Hi guys,

I'm almost done customizing my pro sites membership site. Only a small thing is bugging me.

When a Payment has been successful (Stripe) it shows a blank page with the text "Payment successful.. press here to go to your site.." (or similar).

It is kind of unneccesary and makes it look a tad unprofessional as that's the only thing on the page. For me it would be much better if it would just redirect directly to the users dashboard (wp-admin). Is there a way to do that?

  • Ash

    Hello @Nick

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

    When a Payment has been successful (Stripe) it shows a blank page with the text "Payment successful.. press here to go to your site.." (or similar).

    Do you mean just this text without any header or footer?

    If yes, would you please activate your default theme and check the issue? Please post a screenshot of that page.

    Cheers
    Ash

  • Ash

    Hello @Nick

    Now I see what you mean.

    You can't just redirect instead of that page, but you can set an auto redirect from this page. In that case, you can use this script:

    add_filter( 'psts_checkout_output', 'my_csutom_output' );
        function my_csutom_output() {
            switch_to_blog( $_REQUEST['bid'] );
            $url = get_bloginfo( 'url' );
            ?>
            <script type="text/javascript">
                window.location.href = '<?php echo $url ?>/wp-admin';
            </script>
            <?php
        }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

  • Hoang Ngo

    Hi @Nick,

    I hope you are well today.

    So I assume that you are using the strip gateway, here is the steps for modify.

    1. Open this file /pro-sites/pro-sites-files/gateways/gateway-stripe.php
    2. In line 1251, you will see the code look like this

    if ( $this->complete_message ) {
    			$content = '<div id="psts-complete-msg">' . $this->complete_message . '</div>';
    			$content .= '<p>' . $psts->get_setting( 'stripe_thankyou' ) . '</p>';
    			$content .= '<p><a href="' . get_admin_url( $blog_id, '', 'http' ) . '">' . __( 'Visit your newly upgraded site &raquo;', 'psts' ) . '</a></p>';
    
    			return $content;
    		}

    Please update it too

    if ( $this->complete_message ) {
    			$content = '<div id="psts-complete-msg">' . $this->complete_message . '</div>';
    			$content .= '<p>' . $psts->get_setting( 'stripe_thankyou' ) . '</p>';
    			$content .= '<p><a href="' . get_admin_url( $blog_id, '', 'http' ) . '">' . __( 'Visit your newly upgraded site &raquo;', 'psts' ) . '</a></p>';
                $content.='<script type="text/javascript">location.href="'.get_admin_url( $blog_id, '', 'http' ).'"</script>';
    			return $content;
    		}

    This should display the message, and auto redirect user to his new upgrade site.

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang Ngo

  • Hoang Ngo

    Hi @Nick,

    I hope you are well today.

    So you can update the code
    $content.='<script type="text/javascript">location.href="'.get_admin_url( $blog_id, '', 'http' ).'"</script>';
    To this
    $content.='<script type="text/javascript">setTimeout(function(){location.href="'.get_admin_url( $blog_id, '', 'http' ).'"},5000)</script>';
    This will give you 5 seconds before redirect :slight_smile:

    If you have any issues please don't hesitate to let us know so we can assist

    Best regards,
    Hoang Ngo

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.