Description
This function counts the number of users that has a given badge with the option to count badge level.
Returns
(int) The number of users that has a badge or badge level.
Parameters
Param | Type | Required | Description | |
---|---|---|---|---|
function mycred_count_users_with_badge( |
||||
$badge_id |
int | Yes | The badge post object ID. |
|
$level |
int | No | Option to count a specific level for the given badge. |
|
) { ... } |
Example
Example 1: Count the number of users that have a badge with the id 1.
$badge_id = 1; $count = mycred_count_users_with_badge( $badge_id ); printf( '%d users have earned this badge', $count );