LLMS_Controller_Account::redeem_voucher()
Redeem a voucher from the “Redeem Voucher” endpoint of the student dashboard
Return Return
(null|true|WP_Error) Returns null
when the form hasn't been submitted, there's a nonce error, or there's no logged in user. Returns true
on success and an error object when an error is encountered redeeming the voucher.
Source Source
File: includes/forms/controllers/class.llms.controller.account.php
public function redeem_voucher() { if ( ! llms_verify_nonce( 'lifterlms_voucher_nonce', 'lifterlms_voucher_check' ) || ! get_current_user_id() ) { return null; } $voucher = new LLMS_Voucher(); $redeemed = $voucher->use_voucher( llms_filter_input_sanitize_string( INPUT_POST, 'llms_voucher_code' ), get_current_user_id() ); if ( is_wp_error( $redeemed ) ) { llms_add_notice( $redeemed->get_error_message(), 'error' ); return $redeemed; } llms_add_notice( __( 'Voucher redeemed successfully!', 'lifterlms' ), 'success' ); return true; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.9.0 | Stop using deprecated FILTER_SANITIZE_STRING . |
4.12.0 | Introduced. |