Redirect users after WooCommerce checkout – LearnDash Dev Docs

PHOTO EMBED

Tue Dec 27 2022 08:55:34 GMT+0000 (Coordinated Universal Time)

Saved by @Roelinde ##learndash ##woocommerce

/*
*
* 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;
	}
}
content_copyCOPY

https://developers.learndash.com/snippet/redirect-users-after-woocommerce-checkout/