A free points management plugin for WordPress.
myCRED Logo
myCRED Logo
  • Membership New
  • Chapters
    • Chapter I – Introduction
    • Chapter II – Getting Started
    • Chapter III – Add-ons
    • Chapter IV – Premium Add-ons
    • Chapter V – For Developers
    • Chapter VI – Reference Guides
  • Categories
    • Actions
    • Classes
    • Constants
    • Filters
    • Functions
    • Objects
    • Shortcodes
    • Hooks
    • Template Tags
  • Packages
    • mycred/api
    • mycred/badge
    • mycred/balance
    • mycred/banking
    • mycred/content
    • mycred/core
    • mycred/coupon
    • mycred/email
    • mycred/game
    • mycred/log
    • mycred/notice
    • mycred/payment
    • mycred/purchase
    • mycred/rank
    • mycred/transfer
  • Store
  • Download
    Navigation
    • Loading navigation ...
    All Objects
    myCRED objects
    1. myCRED_Account
    2. myCRED_Badge
    3. myCRED_Balance
    4. myCred_Chart
    5. myCRED_Email
    6. myCRED_History
    7. myCRED_Point_Type
    8. myCRED_Rank
    9. myCRED_Transfer
    Categories
    Filter by category
    1. Actions
    2. Classes
    3. Filters
    4. Functions
    5. Hooks
    6. Objects
    7. Shortcodes
    8. Template Tags
    Chapters
    Documentation
    1. Chapter I - Introduction
    2. Chapter II - Getting Started
    3. Chapter III - Add-ons
    4. Chapter IV - Premium Add-ons
    5. Chapter V - For Developers
    6. Chapter VI - Reference Guides
myCRED_Account

Codex / mycred/core / Objects / 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
        )
)
0

About myCred

myCred is a free, open-source and developer friendly points management tool for WordPress powered websites.

Download Rate Plugin

Documentation

  • Add-ons
  • Core Shortcodes
  • F.A.Q.
  • Tutorials
  • Third Party Plugins
  • Code Snippets

Support

  • Product Licenses
  • Customization
  • Support Forums
  • Plugin Changelog
  • Contact

Copyright 2013 - 2021 by WPExperts; All rights reserved. myCred is licensed under GPL 2.0

Terms & Conditions • Use of Cookies • Store Policy • Community Rules

Suggest Codex Example

You can submit suggestions for codex examples that you have available as a public gist. If you are a member on the mycred.me website, you can earn Tokens for each submission. To claim these Tokens, make sure you provide your mycred.me username.

Please make sure the example you submit is relevant and if you include documentation, it's provided in English.

logo
  • Membership New
  • Chapters
    • Chapter I – Introduction
    • Chapter II – Getting Started
    • Chapter III – Add-ons
    • Chapter IV – Premium Add-ons
    • Chapter V – For Developers
    • Chapter VI – Reference Guides
  • Categories
    • Actions
    • Classes
    • Constants
    • Filters
    • Functions
    • Objects
    • Shortcodes
    • Hooks
    • Template Tags
  • Packages
    • mycred/api
    • mycred/badge
    • mycred/balance
    • mycred/banking
    • mycred/content
    • mycred/core
    • mycred/coupon
    • mycred/email
    • mycred/game
    • mycred/log
    • mycred/notice
    • mycred/payment
    • mycred/purchase
    • mycred/rank
    • mycred/transfer
  • Store
  • Download