myCRED_Account

Description

The account object is an “umbrella” object of a given users myCRED related data. This includes their balance, history and data related to any add-ons that are enabled in your installation.

Available since version 1.7

Interacting with Object

The account object can be accessed via the mycred_get_account function.

Object properties

Property Type Description
myCRED_Account Object (
public $user_id int The users WordPress ID.
public $point_types array An array of point type keys that the user is not excluded from.
public $balance array An array of myCRED_Balance objects for all existing point types. If a user is excluded from a certain type, the value for the point type will be FALSE instead of a Point Type Object.
public $total_balance int or float All current balances added up into one lump sum.
public $history array An array of point type keys that the user has log entries for. This property is only available if the Log module is enabled.
public $badges array An array of myCRED_Badge objects that a user has earned or been assigned. This property is only available if the Badges add-on has been enabled.
public $badge_ids array An array of badge IDs and the level the user has reached. Note that badge levels start with the ID zero.This property is only available if the Badges add-on has been enabled.
public $ranks array The total number of ranks a user has. In most cases this is 1 but if you have ranks setup for multiple point types, this would equal to the number of point types a user has access to. This property is only available if the Ranks add-on has been enabled.
)

Object Methods

public function __construct( $user_id = NULL ) {
Description: Constructs the account object if a valid user ID is provided.
Variable Type Required Description
$user_id int Yes The users numeric ID.
}
public function get_balance( $type_id = MYCRED_DEFAULT_TYPE_KEY ) {
Description: Retrieves the myCRED_Balance object of a given point type.
Variable Type Required Description
$type_id string No The point type key of the balance to return.
}

Object Example

myCRED_Account Object
(
    [user_id] => 1
    [point_types] => Array
        (
            [0] => mycred_default
            [1] => mycred_deed
        )

    [balance] => Array
        (
            [mycred_default] => myCRED_Balance Object
                (
                    [current] => 4455
                    [accumulated] => 4874
                    [point_type] => myCRED_Point_Type Object
                        (
                            [cred_id] => mycred_default
                            [singular] => Token
                            [plural] => Tokens
                            [prefix] => 
                            [suffix] => tk.
                            [format] => Array
                                (
                                    [type] => bigint
                                    [decimals] => 0
                                    [separators] => Array
                                        (
                                            [decimal] => .
                                            [thousand] => ,
                                        )

                                )

                        )

                )

            [mycred_deed] => myCRED_Balance Object
                (
                    [current] => -203
                    [accumulated] => 47
                    [point_type] => myCRED_Point_Type Object
                        (
                            [cred_id] => mycred_deed
                            [singular] => Deed
                            [plural] => Deeds
                            [prefix] => 
                            [suffix] => de.
                            [format] => Array
                                (
                                    [type] => bigint
                                    [decimals] => 0
                                    [separators] => Array
                                        (
                                            [decimal] => .
                                            [thousand] => ,
                                        )

                                )

                        )

                )

        )

    [total_balance] => 54689
    [history] => Array
        (
            [0] => mycred_default
            [1] => mycred_credit
        )
)