Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Display earned badges for a given user FORUM
- *
- * @param array $atts Our attributes array
- * @return string Concatenated markup
- */
- function prefix_badgeos_user_achievements_shortcode_forum( $atts = array() ) {
- // Parse our attributes
- $atts = shortcode_atts( array(
- 'user' => bbp_get_reply_author_id(),
- 'type' => 'award',
- 'limit' => 5
- ), $atts );
- $output = '';
- // Grab the user's current achievements, without duplicates
- $achievementsforum = array_unique( badgeos_get_user_earned_achievement_ids( $atts['user'], $atts['type'] ) );
- // Setup a counter
- $count = 0;
- // Loop through the achievements
- if ( ! empty( $achievementsforum ) ) {
- $output .= '<div class="user_awards">User Awards</div>';
- $output .= '<div class="badgeos-user-badges-wrap-forum">';
- foreach( $achievementsforum as $achievement_forum_id ) {
- // If we've hit our limit, quit
- if ( $count >= $atts['limit'] ) {
- break;
- }
- // Output our achievement image and title
- $output .= '<div class="badgeos-badge-wrap-forum">';
- $output .= badgeos_get_achievement_post_thumbnail( $achievement_forum_id );
- $output .= '</div>';
- // Increase our counter
- $count++;
- }
- $output .= '</div>';
- }
- return $output;
- }
- add_shortcode( 'custom_badgeos_user_achievements_forum', 'prefix_badgeos_user_achievements_shortcode_forum' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement