LLMS_Voucher::get_redemptions_for_code_by_user( int $code_id, int $user_id )

Retrieve the number of times a voucher was redeemed by a specific user


Description Description

Hint, it should always be 1 or 0


Top ↑

Parameters Parameters

$code_id

(int) (Required) Voucher Code ID from wp_lifterlms_vouchers_codes table.

$user_id

(int) (Required) User ID from wp_users tables.


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/class.llms.voucher.php

	public function get_redemptions_for_code_by_user( $code_id, $user_id ) {

		global $wpdb;

		return $wpdb->get_var(
			$wpdb->prepare(
				"SELECT count(id) FROM {$this->get_redemptions_table_name()} WHERE user_id = %d and code_id = %d", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
				array( $user_id, $code_id )
			)
		);

	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.