Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I place badges under users avatar on forums ?

Viewing 4 replies - 1 through 4 (of 4 total)

  • Robkk
    Moderator

    @robkk

    theres a bunch of plugins that do this type of thing

    badge OS like you said
    mycred can show some badges
    achievements for wordpress also does this
    userpro has this kind of thing too

    do a search and see what is the best fit for you


    Divvy
    Participant

    @divvy

    Hey,

    Sorry, I know that this topic have almost 3 years old, but I have a solution.
    I’m going to add here in case there is more people looking for the same.

    I have found this code to place badges (achievements) under user avatar in bbpress:

    add_filter( 'bbp_get_reply_author_link', 'my_append_badges_via_filter', 10, 2 );
    
    function my_append_badges_via_filter($author_link = '', $args) {
    
    	# Needed to get the user ID of the person intended to be displayed.
    	$user_id = bbp_get_reply_author_id( $args['post_id'] );
    	#Construct your output here.
    	$badge_output = '';
    
    	$achievements = badgeos_get_user_achievements( array( 'user_id' => $user_id ) );
    	if ( !empty( $achievements ) ) {
    			$badge_output .= '<div class="achievements">';
            foreach ( $achievements as $achievement ) {
    						if($achievement->post_type != 'badges')
    							continue;
                $badge_output .= '<div class="achievement achievement-' . $achievement->post_type . '">';
                //echo '<h2>' . get_the_title( $achievement->ID ) . '</h2>';
                $badge_output .= get_the_post_thumbnail( $achievement->ID, 'thumbnail', array('title'=>get_the_title( $achievement->ID ) ) );
                //echo __( 'Earned on: ', 'text-domain' ) . date( get_option( 'date_format' ), $achievement->date_earned ) ;
                $badge_output .= '</div>';
            }
    			$badge_output .= '</div>';
      } 
    		
    	return  $author_link . $badge_output;
    }

    To make badge smaller I added this CSS code:

    .achievement.achievement-badges{width:50px;}

    But the code is not perfect. Because is not showing badges only under avatar, is also showing at:
    – forums main page
    – forum page
    – above topic (information bar)

    Would be great too if have:
    – link in badges to archivements tab page

    Can someone help me with this? 🙂

    Thanks!!


    Robin W
    Moderator

    @robin-w

    bbp user ranking does this

    bbp user ranking


    Divvy
    Participant

    @divvy

    True, but not so powerful as this one.

    Does anyone know how to add a link in the badges to archivements tab page?

    I think that we need to change this line of code:
    $badge_output .= get_the_post_thumbnail( $achievement->ID, 'thumbnail', array('title'=>get_the_title( $achievement->ID ) ) );

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar