mycred_leaderboard

Description

This shortcode allows you to create leaderboards that are based on either your users current / total balances or based on events in the log, e.g. a leaderboard showing who gained most points from approved comment or published content.

Available since version 1.3

Shortcode Attributes

Attribute Type Required Default Description
number int No 25 The number of users to show in the leaderboard.
order string No DESC Order of the leaderboard. Accepts "DESC" for descending and "ASC" for ascending.
offset int No 0 Option to offset the leaderboard from the first position.
type string No mycred_default The point type to base the leaderboard on. Should not be used if you only have one point type installed.
based_on string No balance Option to base the leaderboard on users balance (balance) or a particular reference. For example basing a leaderboard on who got most points for approved comments.
total int No 0 When showing a leaderboard based on balances, you can select to use users total balance (1) instead of their current balance (0). Added in 1.7.5.
wrap string No li The wrapping element to use for the list. By default the leaderboard renders an organized list (ol) and each item uses a list element (li).
template string No #%position% %user_profile_link% %cred_f% The template used for each row in the leaderboard. Accepts user related template tags and amount related template tags.
nothing string No Leaderboard is empty The message to show users when the leaderboard is empty.
current int No 0 Option to append the current users position to the bottom of the leaderboard if the user is not in the list. Use 1 to show the user or 0 to skip.
exclude_zero int No 1 Option to filter out users with zero balances / results. Use 1 to enable and 0 to disable.
timeframe string No - If the leaderboard is based on references, you can set a timeframe for the leaderboard. Accepts the keywords "today" for todays leaderboard, "this-week" for this weeks leaderboard, "this-month" for this months leaderboard or a well formatted date to start from.

CSS Styling

// Organized list leaderboards
ol.myCRED-leaderboard { }

// First user row
ol.myCRED-leaderboard li.first { }

// Alternating row
ol.myCRED-leaderboard li.alt { }

// If leaderboard is empty
p.mycred-leaderboard-none { }

Examples

Example 1: Show a leaderboard based on balances with the top 10 users.

[mycred_leaderboard number=10]

Example 2: Show bottom 10 users with the lowest balance first.

[mycred_leaderboard number=10 order="ASC"]

Example 3: First show the top 3 users then in a new shortcode we show the next 10 users down the list.

Top 3 Users:
[mycred_leaderboard number=3]

Next 10:
[mycred_leaderboard number=10 offset=3]

Example 4: Show top 3 users without the profile link just showing their display name.

[mycred_leaderboard number=3 template="#%position% %display_name% %cred_f%"]

Example 5: Use HTML in your row template

[mycred_leaderboard number=3]
#%position% <strong>%display_name%</strong>
[/mycred_leaderboard]

Example 6: Instead of an organized list, create a table. (requires myCRED 1.1.2)

<table>
	<thead>
		<tr>
			<th>Position</th>
			<th>Name</th>
			<th>Points</th>
		</tr>
	</thead>
	<tbody>
	[mycred_leaderboard wrap=""]
		<tr>
			<td>%position%</td>
			<td>%display_name%</td>
			<td>%cred_f%</td>
		</tr>
	[/mycred_leaderboard]
	</tbody>
</table>

Example 7: Show a leaderboard for users who have spent most points in your WooCommerce store.

[mycred_leaderboard based_on="woocommerce_payment" order="ASC"]