Displaying Badges

Estimated reading: 2 minutes 2889 views

Displaying Badges

The add-on provides several tools to help you display badges on your website. You can use shortcodes or functions and if are using BuddyPress or bbPress, the add-on can help you automatically insert them into your users profiles.

Shortcodes

The add-on has two build in shortcodes for displaying badges:

  • mycred_my_badges – This shortcode allows you to show a specific users or the current users badges.
  • mycred_badges – This shortcode allows you to show your users all the published badges existing on your website with an option to also include the badges’ requirement(s).
  • mycred_badges_list – This shortcode allows you to display all published badges that have ever existed on your website and define them under their respective achievement types.

Third-party Plugins

These settings are only visible if BuddyPress or bbPress is installed.
 

If you are using BuddyPress, the badges add-on can help you insert a users badges directly into their profiles without the need to use any shortcode. To do so, simply visit your myCred Settings page and under “Badges” select where you want to show the badges.

 

Badge Functions

You can show badges using the shortcodes in combination with the do_shortcode function as an example or you can use functions that the add-on provides. Here are a few functions that could be useful:

FunctionDescription
mycred_get_users_badgesReturns an array of badge post IDs that a particular user has earned. Array keys represent the badge post ID while values represent levels.
mycred_display_users_badgesRenders a list of badge images a particular user has earned.
mycred_display_badge_requirementsReturns the requirements set for a particular badge.