$object = new myCRED_Badge();

Codex / mycred/badge / Objects / myCRED_Badge

Description

The badge object holds the badge levels, each levels requirements and badge images.

Available since version 1.7

Properties

Note that the constructor class will auto populate these values when the class is constructed.

Property Type Description
myCRED_Badge Object (
post_id int The badge post objects ID.
title string The badge title.
earnedby int The number of users that has earned this badge.
manual bool Indicates if the badge has been set to be manually awarded.
levels array Array of all the levels setup for this badge.
level array If a particular level is requested when the object is constructed, that selected levels settings are populated here.
level_label int If a particular level is requested when the object is constructed, that selected levels title is populated here.
level_image string If a particular level is requested when the object is constructed, that selected levels image is populated here.
main_image string The main badge image (if set).
image_width int The set value for the MYCRED_BADGE_WIDTH constant.
image_height int The set value for the MYCRED_BADGE_HEIGHT constant.
)

Methods

Variable Type Required Description
class myCRED_Badge extends myCRED_Object {
function __construct( $badge_id = NULL, $level = NULL ) {
$badge_id int Yes The badge post ID.
$level int No The badge level to populate.
}
public function get_image( $image = NULL ) {
$image string No The image to return. Accepts main to get the main image or the badge level.
}
}

Associated Functions

The badge object can be accessed via the mycred_get_badge function.

Object Example

myCRED_Badge Object
(
    [post_id] => 11516
    [title] => Spender
    [earnedby] => 0
    [manual] => 
    [levels] => Array
        (
            [0] => Array
                (
                    [attachment_id] => 0
                    [image_url] => 
                    [label] => 
                    [compare] => AND
                    [requires] => Array
                        (
                            [0] => Array
                                (
                                    [type] => mycred_default
                                    [reference] => approved_comment
                                    [amount] => 3
                                    [by] => count
                                )

                            [1] => Array
                                (
                                    [type] => mycred_default
                                    [reference] => visitor_referral
                                    [amount] => 1
                                    [by] => count
                                )

                        )

                    [reward] => Array
                        (
                            [type] => mycred_default
                            [log] => 
                            [amount] => 0
                        )

                )

            [1] => Array
                (
                    [attachment_id] => 0
                    [image_url] => 
                    [label] => 
                    [compare] => AND
                    [requires] => Array
                        (
                            [0] => Array
                                (
                                    [type] => mycred_default
                                    [reference] => approved_comment
                                    [amount] => 10
                                    [by] => count
                                )

                            [1] => Array
                                (
                                    [type] => mycred_default
                                    [reference] => visitor_referral
                                    [amount] => 10
                                    [by] => count
                                )

                        )

                    [reward] => Array
                        (
                            [type] => mycred_default
                            [log] => 
                            [amount] => 0
                        )

                )

        )

    [level] => 
    [level_label] => 
    [level_image] => 
    [main_image] => <img src="http://website.com/level-image.png" alt="" />
    [image_width] => 100
    [image_height] => 100

Last edited June 23, 2016