mycred_coupon_was_successfully_used

Description

This function checks if a coupon was successfully applied or not. Should be used in combination with the mycred_use_coupon function.

This function is only available if the Coupons add-on is enabled.

Available since version 1.7.5

Returns

(bool) TRUE if the coupon was successfully applied else FALSE.

Parameters

Param
Type
Required
Description

function mycred_coupon_was_successfully_used(

$code

Yes

The results of the mycred_use_coupon function.

) { ... }

Examples

Example 1: Apply a posted coupon code to the current user.

$user_id = get_current_user_id();
$code    = $_POST['coupon'];

$results = mycred_use_coupon( $code, $user_id );

if ( mycred_coupon_was_successfully_used( $results ) ) {

	// Coupon was successfully used

}
else {

	// Something went wrong

}