Shortcode Description
This shortcode allows you to show a given users or the current users position in a particular leaderboard. Nothing will be returned if the user viewing the shortcode is not logged in.
Requirements
- myCRED 1.4 or higher.
Usage in content
[mycred_my_ranking]
Usage in theme files
echo do_shortcode( '[mycred_my_ranking]' );
Shortcode Attributes
Attribute | Type | Default | Required |
---|---|---|---|
user_id |
( int ) | current user |
no |
Option to show a particular users leaderboard position. Will default to the current users ID if not set. |
Attribute | Type | Default | Required |
---|---|---|---|
ctype |
( string ) | mycred_default |
no |
The point type in question for the leaderboard. |
Attribute | Type | Default | Required |
---|---|---|---|
based_on |
( string ) | balance |
no |
Option to set what the leaderboard is based on in order to get the users position. This can either be their current balance (balance) or a reference. |
Attribute | Type | Default | Required |
---|---|---|---|
missing |
( int|string) | 0 |
no |
Option to set what to return when a user does not have a position in the leaderboard. |
CSS Styling
This shortcode does not render any style-able elements.
Examples
Example 1: Get the current users position in a leaderboard based on most points gained for approved comments.
[mycred_my_ranking based_on="approved_comment"]
Example 2: Get the current users leaderboard position for the custom point type “cointype”.
[mycred_my_ranking ctype="cointype"]