Redirect to thank you page after pro sites purchase

How do I redirect to thank you page after pro sites purchase, or how can we use the FB pixel to track purchases?

  • Ivan

    Hi robertvideo !

    You could try adding the following snippet in a MU plugin ( more info about MU plugins is here )

    <?php
    function wpmu_pro_sites_add_script_to_checkout( $content, $blog_id, $domain ) {
    	if ( strpos( $content, 'psts-payment-info-received' ) ) {
    		$content .= <<<EOT
    				<script>
    					/* add the script here */
    				</script>
    EOT;
    	}
    	return $content;
    }
    add_action( 'prosites_render_checkout_page', 'wpmu_pro_sites_add_script_to_checkout', 99, 3 );

    this code is for adding JS-script. Or you can try this snippet for redirect to custom page.

    <?php
    function wpmu_pro_sites_add_script_to_checkout( $content, $blog_id, $domain ) {
    	if ( strpos( $content, 'psts-payment-info-received' ) ) {
    		wp_redirect( 'YOUR_URL' );
    		exit;
    	}
    	return $content;
    }
    add_action( 'prosites_render_checkout_page', 'wpmu_pro_sites_add_script_to_checkout', 99, 3 );

    Note: you should replace YOUR_URL to your real URL.
    Also, both scripts will work both for payment_submitted action and for account_modified and manual_submitted and free_confirmation actions too.

    Best regards,
    Ivan.

  • Lindeni Mahlalela

    Hello robertvideo

    I hope you are doing great today. I am sorry for the late reply from our side.

    The two code snippets suggested by my colleague Ivan above are options, so you should use the JS or the other snippet below that. The first snippet requires that you write some custom JavaScript and put it in place of:

    /* add the script here */

    If you are not comfortable writing JavaScript then you should try the second option which only requires that you replace 'YOUR_URL' with the url you want the users to be redirected to after successful signup. So to answer your question:

    DO I literally replace YOUR_URL with https://mydomain.com/thankyou.php

    Yes, that is what you need to do, so the second snippet becomes:

    <?php
    function wpmu_pro_sites_add_script_to_checkout( $content, $blog_id, $domain ) {
    	if ( strpos( $content, 'psts-payment-info-received' ) ) {
    		wp_redirect( 'https://mydomain.com/thankyou.php' );
    		exit;
    	}
    	return $content;
    }
    add_action( 'prosites_render_checkout_page', 'wpmu_pro_sites_add_script_to_checkout', 99, 3 );

    You should put the code in a new php file and upload it to your website in 'wp-content/mu-plugins' for example create a new .php file and call it 'pro-sites-signup-redirect.php' and upload it to the location:

    wp-content/mu-plugins/pro-sites-signup-redirect.php

    Alternatively, you can put the code in your theme's functions.php file, if you choose this then remember to remove the opening php tag: <?php

    I hope this answers your questions, please let us know if you have any further questions.

    Have a nice day.
    Mahlamusa