Redirect a user once they have signed up and paid for a site

A couple of my customers have complained to me that the sign-up process for a new site is a little bit confusing, I actually had one client accidentally pay twice! The general feeling is that once a user has paid, it’s kind of confusing to go back to their account page – I think it would be better to redirect to a different page, or better still, straight to the dashboard so users can start building their site right away.

Is there a way to set up a redirect once a site has been created and payment has been successful?

  • Jude
    • DEV MAN

    Hey @samuel

    Thanks for getting in touch !

    What you are looking at is possible. Simply use a action hook like this one wpmu_new_blog.

    For example

    add_action( 'wpmu_new_blog' , function() { wp_redirect('http://google.com';  } ) ;

    Just copy/paste the code into the functions.php file of your child theme or a site specific plugin if you use one.

    Cheers

    Jude

  • Jude
    • DEV MAN

    Hey @samuel

    Here you go ..

    function wpmu_new_blog_redirect( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
    wp_redirect( get_admin_url( $blog_id ) ) ;
    }
    add_action( 'wpmu_new_blog', 'wpmu_new_blog_redirect', 10, 6 );

    This is an expanded version of the code that does what you asked for

    Jude

  • Michael Bissett
    • Recruit

    Hey Samuel, Michael here!

    When I use this code inside of a mu-plugin:

    <?php

    add_filter( 'wpmu_new_blog', 'wpmu_new_blog_redirect' );

    function wpmu_new_blog_redirect( $blog_id ) {
    $url = get_admin_url( $blog_id )
    ?>
    <script type="text/javascript">
    jQuery(window).load(function() {
    jQuery(document).ready(function() {
    window.location.href = '<?php echo $url ?>';
    });
    });
    </script>
    <?php
    }

    When a successful registration has been done (with the “Finalizing your site…” content being visible), after that content’s been displayed, the page redirects to the dashboard for the subsite signed up for.

    To create a mu-plugin, you’ll want to log into your site via FTP, and go to your /wp-content/ folder via FTP, finding the folder called “mu-plugins”.

    If there’s no folder with that name, then you’ll want to create one. Then, create a file inside that folder, and give the file any name you like (making sure the file has an extension of .php, e.g. example.php) and paste the code in there.

    It’ll always be active, so there’s no need to activate the plugin after creation. Be sure to add a PHP start tag at the beginning of the code, like what I’ve got at the beginning of the snippet posted here.

    If you’re wanting to hide the “Finalizing your site…” information, you could insert this CSS code into either your child theme’s style.css file, or a plugin like Simple Custom CSS:

    div#psts-payment-info-received {
    display: none;
    }

    Kind Regards,

    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.