Since leaderboards can be based on so many different things, the plugin was made as developer friendly as possible, in order to allow customizations. In this guide, I will walk you through how a custom leaderboard type that will allow us to generate a leaderboard for our current year.

This guide requires basic understanding of PHP and WordPress development.

Add Our Custom Type

First, we will need to add our type the list of leaderboard types that are shown in the admin area. This list is also used to tell the plugin that a custom type might exists. We will do this using the mycred_bp_leaderboard_types filter. You can use this filter not just to add your own type but also to rename existing ones or for example removing unwanted types.

The Leaderboard Query

Next we need to handle the database query and setup of our leaderboard type. This is by far the most important function. To do this, we can use the mycred_bp_leaderboard_get filter. Our custom function needs to check if a cached leaderboard exists, if not query a new one and add support for appending users to the end of the leaderboard (if enabled).

The Position Query

Finally we need to handle a users leaderboard position. For this, we will be using the mycred_bp_leaderboard_find_position filter. This is mainly used when a user is appended to a leaderboard (assuming it is something you use). If this is not done, all appended users position will be the total number of group members.

It is important to remember that unlike the mycred_bp_leaderboard_get filter, this filter only runs when a users cached position has been deleted and a new query is needed.

myCRED Donations

Donate via PayPal

Donate Bitcoin

3LVrDPjgTkPfqGARXwAZW9cJBQEYo4FHsB

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.

Gist URL

mycred.me Username

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