mycred_assign_badge

Description

This function assigns a given badge to all users that meet the set requirements.

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

Available since version 1.7

Returns

(array) Returns an array of User IDs and the level their reached for this badge.

Parameters

Param Type Required Description
function mycred_assign_badge(
$badge_id int Yes

The badge post object ID.

) { ... }

Examples

Example 1: Assign a badge and show the number of users that received it.

$badge_id = 1;

$results  = mycred_assign_badge( $badge_id );
printf( '%d users earned this badge.', count( $results ) );