Browse: Home / Snippets /

Redirect users after WooCommerce checkout

Contents


Snippet #

Important: All snippets are provided as-is without support or guarantees. These snippets are provided as guidelines for advanced users looking to customize LearnDash. For any additional help or support with these snippets, we recommend reaching out to a LearnDash Expert.

/*
*
* Redirect users after checkout
* Original code taken from: https://gist.github.com/webmasterninjay/45fd3fad114a6a4a2862
*
*/

add_action( 'template_redirect', 'ld_custom_redirect_after_purchase' );

function ld_custom_redirect_after_purchase() {
	global $wp;
	
	if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
    
        // Change the URL below to the URL you want your customer to be redirected to. 
        // We recommend redirecting users to their LD User Profile Page
		wp_redirect( 'http://www.yoururl.com/user-profile-page' );

        exit;
	}
}