Codex / mycred/balance / Shortcodes / mycred_my_balance


This shortcode allows you to show the balance of the user viewing the shortcode or a specific user. By default, the balance is displayed formatted with a wrapping element, however these can be disabled and you can show a balance inline without any formatting.

Available since version 1.0.9

Shortcode Attributes

Attribute Type Required Default Description
user_id string No current Option to show the balance of a particular user. Accepts "current" for current user or a user ID.
title string No - Option to show a "title" before the balance element.
title_el string No h1 If a title is set, you can set the HTML element to wrap around the title.
balance_el string No div The balance element wrapping element. Set to empty if you do not want to use this.
wrapper int No 1 Option to wrap the title / balance elements around with a wrapping element (1) or to hide this wrapping element (0).
formatted int No 1 Option to show the balance formatted (1) with a prefix / suffix or show without any formatting (0). Added in 1.7
type string No MYCRED_DEFAULT_TYPE_KEY The point type to show. Should not be used if you only have one point type installed.

CSS Styling

// outer weapper (if used)
.mycred-my-balance-wrapper { }

// balance title element (if used)
.mycred-my-balance-wrapper h1 { }

// balance wrapper (if used)
.mycred-my-balance-wrapper div {}


Example 1: Default usage.


Example 2: Show message for logged out users. (Note that the previous ``login`` shortcode attribute was removed as of version 1.7)

[mycred_my_balance]Please login to view your balance[/mycred_my_balance]

Example 3: Remove all wrappers and only show the balance. (required 1.3 or higher)

[mycred_my_balance wrapper=0 title_el="" balance_el=""]

Example 4: Show balance for a custom point type that has the meta key “mytype”.

[mycred_my_balance type="mytype"]

Last edited February 1, 2017