mycred_get_badge

Description

This function returns the myCRED Badge Object for a given badge ID.

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

Available since version 1.7

Returns

(bool | object) Returns either the Badge object or FALSE if the ID is invalid or does not belong to a badge post type.

Parameters

Param Type Required Description
function mycred_get_badge(
$badge_id int Yes

The badge post object ID.

$level int No

Option to construct the object around a particular badge level. This in turn pre-loads level related details like the level image.

) { ... }

Examples

Example 1: Display a given badges main image.

$badge_id = 1;
$badge    = mycred_get_badge( $badge_id );

echo $badge->main_image;