Displaying Badges
Estimated reading: 2 minutes
4520 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
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:
Function | Description |
---|---|
mycred_get_users_badges | Returns 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_badges | Renders a list of badge images a particular user has earned. |
mycred_display_badge_requirements | Returns the requirements set for a particular badge. |