mycred_get_users_coupon_count

Description

This function returns the total number of times a user has redeemed a specific coupon.

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

Available since version 1.4

Returns

(int) The number of times the coupon has been used.

Parameters

Param Type Required Description
function mycred_get_users_coupon_count(
$code string Yes

The coupon code. Note that this function checks the code and not the post ID.

$user_id int Yes

The users numeric ID.

) { ... }

Examples

Example 1: Check the number of times a user has used our holiday coupon.

$coupon_code = 'XMASOFFER';
$user_id     = get_current_user_id();
$count       = mycred_get_users_coupon_count( $coupon_code, $user_id );

printf( 'You have used this coupon %d times', $count );