LLMS_Controller_Account::cancel_subscription()
Lets student cancel recurring access plan subscriptions from the student dashboard view order screen
Return Return
(void)
Source Source
File: includes/forms/controllers/class.llms.controller.account.php
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | public function cancel_subscription() { // Invalid nonce or the form wasn't submitted. if ( ! llms_verify_nonce( '_cancel_sub_nonce' , 'llms_cancel_subscription' , 'POST' ) ) { return ; } elseif ( empty ( $_POST [ 'order_id' ] ) ) { return llms_add_notice( __( 'Something went wrong. Please try again.' , 'lifterlms' ), 'error' ); } $order = llms_get_post( llms_filter_input( INPUT_POST, 'order_id' , FILTER_SANITIZE_NUMBER_INT ) ); $uid = get_current_user_id(); if ( ! $order || $uid != $order ->get( 'user_id' ) ) { return llms_add_notice( __( 'Something went wrong. Please try again.' , 'lifterlms' ), 'error' ); } $note = __( 'Subscription cancelled by student from account page.' , 'lifterlms' ); // Active subscriptions move to pending-cancel. // All other statuses are cancelled immediately. if ( 'llms-active' === $order ->get( 'status' ) ) { $new_status = 'pending-cancel' ; $note .= ' ' . __( 'Enrollment will be cancelled at the end of the prepaid period.' , 'lifterlms' ); } else { $new_status = 'cancelled' ; } $order ->set_status( $new_status ); $order ->add_note( $note ); /** * Action triggered after a recurring subscription is cancelled from the student dashboard by the student. * * @since 3.17.8 * * @param LLMS_Order $order The order object. * @param integer $uid The WP_User ID the student who cancelled the subscription. */ do_action( 'llms_subscription_cancelled_by_student' , $order , $uid ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.35.0 | Sanitize $_POST data. |
3.19.0 | Unknown. |
3.10.0 | Introduced. |