Skip to content

Instantly share code, notes, and snippets.

@thomasplevy
Last active January 20, 2018 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasplevy/6e5aeec68599e7086b0008cd241f7a38 to your computer and use it in GitHub Desktop.
Save thomasplevy/6e5aeec68599e7086b0008cd241f7a38 to your computer and use it in GitHub Desktop.
<?php // don't add this line to your functions.php file
/**
* Redirect a user after sucessfully purchasing a course or membership
* @param string $url default url
* @param obj $order instance of LLMS_Order
* @return string
*/
function my_llms_checkout_redirect( $url, $order ) {
// if you want to change the destination based on the purchased product
if ( 123 == $order->get( 'product_id' ) ) {
$url = add_query_arg( 'order-complete', $order->get( 'order_key' ), 'http://myurl.tld/product123startpage' );
}
// go to the student dashboard
else {
$url = llms_get_page_url( 'myaccount', array( 'order-complete', $order->get( 'order_key' ) ) );
}
return $url;
}
add_filter( 'lifterlms_completed_transaction_redirect', 'my_llms_checkout_redirect', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment