mycred_count_users_with_badge

Description

This function counts the number of users that has a given badge with the option to count badge level.

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

Available since version 1.5

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.

) { ... }

Examples

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 );