Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@webmasterninjay
Created July 10, 2015 14:41
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmasterninjay/45fd3fad114a6a4a2862 to your computer and use it in GitHub Desktop.
Save webmasterninjay/45fd3fad114a6a4a2862 to your computer and use it in GitHub Desktop.
Woocommerce - Redirect after payment
<?php
/* Redirect user after check out */
add_action( 'template_redirect', 'jay_custom_redirect_after_purchase' );
function jay_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'http://www.yoururl.com/your-page/' );
exit;
}
}
@pintolog
Copy link

Is it possible to redirect the user to the course page after purchase,
so here:
wp_redirect( 'http://www.yoururl.com/your-page/' );
the url will be the course page that the user bought?

@mshafeel
Copy link

How to redirect to the specific learndash course page purchased?

@webmasterninjay
Copy link
Author

I suggest to use the Custom Thank You page plugin for WooCommerce https://wordpress.org/plugins/wc-custom-thank-you/

You will need to edit each Learn Dash Product in Woocommerce and manually add the course page url in the plugin field.

@mshafeel
Copy link

Thank you, what about a custom code? without using the plugin?

@amirhp-com
Copy link

@nishani7234
Copy link

How to modify this code for Redirect to a custom page after checkout based on the user role?
For the membership function, I am using the Ultimate member plugin.

@Collinsmbaka
Copy link

How can I use this code to redirect to the specific course the user purchases?
I have 4 courses on my website, and the user can buy any of the four

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment