Viewing 6 replies - 1 through 6 (of 6 total)
  • Michael Beckwith

    (@tw2113)

    The BenchPresser

    It’s definitely possible to do this, but it’s not done by default with the community addon.

    I recommend looking over this post I wrote up late last year about how to fetch user achievements. http://trexthepirate.com/badgeos/2014/12/show-off-users-achievements-part-one/

    It’s not going to perfectly match up with your specific usecase, as you’re dealing with forum thread reply authors, but it will hopefully give a good early primer.

    Finally, you’re going to need to check bbPress’ hooks to find one that is executed in or around the intended spot for the output. For that, I don’t have an answer as I’d need to dive into the source code myself to find one that’d work.

    @ngrhd Did you manage to find a solution? Myself I’m not rly sure how to do this. What I’ve tried always gave me a 500 error since I don’t rly understand php.

    Would it be possible to execute this shortcode below the reply/topic author in bbPress?
    https://gist.github.com/tw2113/6c31366d094eee6d5151

    Alright, this is what I got so far, using Michael Beckwith’s code in the previous post. Only thing I removed were these lines:

    $output .= '<span class="badgeos-title-wrap">' . get_the_title( $achievement_id ) . '</span>';

    Just because I preferred not to have the title shown under the forum avatar as well.

    If you then add the following code to your child theme’s functions.php, it should work:

    add_action ( 'bbp_theme_after_reply_author_details', 'insert_badges_after_author' );
    function insert_badges_after_author() {
        echo do_shortcode('[custom_badgeos_user_achievements]');
    }

    Michael Beckwith also provided 3 parameters which are very useful for determining what to show under the forum avatar. They can be found in one of the posts here: https://wordpress.org/support/topic/displaying-earned-badges-in-buddypress-profileshortcode?replies=7
    In short they are: user-id, type and limit.

    Hope this can help for people who are amateuristic as me πŸ™‚

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    “Amateuristic” aka future pro πŸ˜‰

    Glad to see you got something worked out here and to your liking.

    Seems I totally forgot to thank you Michael! So thanks πŸ˜›

    One last update (even though I should probably not dig up older/resolved threads, sorry).
    If you’re adding badges under the avatar I’m assuming you’re scaling them down in size, like 30×30 or smaller so they don’t take up all space there or aren’t too distracting.
    Change the following in Michael Beckwith’s code if you want to have a link on the badges, so that when people can’t make them out because they’re small, they’ll be brought right to the badge info:

    // Output our achievement image and title
    $output .= '<div class="badgeos-badge-wrap">';
    $output .= '<a href="' . get_permalink( $achievement_id ) . '">';
    $output .= badgeos_get_achievement_post_thumbnail( $achievement_id );
    $output .= '</a>';
    $output .= '</div>';

    If you’re using badgeOs in tandem with MyCred Ranks you’ll probably want to lower the priority on the code that inserts the badges, so that they appear under the rank. Like this:

    add_action ( 'bbp_theme_after_reply_author_details', 'insert_badges_after_author', 20, 3);
    function insert_badges_after_author() {
        echo do_shortcode('[custom_badgeos_user_achievements]');
    }

    Thanks Michael, BadgeOs does exactly what I want with functionality alternatives don’t have!

    Michael Beckwith

    (@tw2113)

    The BenchPresser

    Even I didn’t notice, but I figured it was implied anyway

    It’s all good. πŸ˜€

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

The topic ‘bbPress show badges under forum post’ is closed to new replies.