Forum Replies Created

Viewing 3 replies - 46 through 48 (of 48 total)
  • Thank you so much, Michael! I added two <br/> codes and it broke to the next line, but still pulls the buttons down. Not a huge deal. Screenshot: https://imgur.com/9rEXLNW

    And, I’m sorry, but I really have no idea what you mean by the counter variables. I am so new to PHP.

    Is that really what you would use to specify the achievements types? I was reading this article: https://trexthepirate.com/badgeos/2014/12/show-off-users-achievements-part-one and saw this:

    badgeos_get_user_achievements() takes an array for its one argument, and it has the following available keys:

    • user_id – The user ID to fetch.
    • site_id – Site ID, if multisite.
    • achievement_id – ID of a specific achievement.
    • achievement_type – Type for a specific achievement group.
    • since – unix timestamp for if wanting since specific date.

    I just don’t know what kind of code to write and where to put it to use the achievement_type key to specify two achievement types. I didn’t see these keys used in the example codes on the page (unless I completely missed them).

    Thank you so much for your help!

    I want to follow this post because I may run into the same issue in the future.

    I’m so close! I used that code on my site, but I can’t for the life of me figure out how to:

    1. Limit it to just two achievements types instead of the four I have and
    2. Break it to the next line after the “Add Friend” “Public Message” and “Private Message” buttons so it doesn’t pull everything down under the profile photo.

    This will look great! Current code in functions.php:

    add_action( 'bp_profile_header_meta', 'display_user_achievements' );
    function display_user_achievements() {
         # Grab their achievement meta data
    $user_achievements = get_user_meta( bp_displayed_user_id(), '_badgeos_achievements', true );
    if ( '' != $user_achievements ) { # only proceed if we have something to display
    	foreach( $user_achievements as $user_achievement ) {
    		foreach( $user_achievement as $achievement ) { # its a slightly messy nested array. Sorry
    			if ( 'step' != $achievement->post_type && badgeos_is_achievement( $achievement->ID ) ) { # we don't want to display steps or possible non-achievement data.
    // Drop any achievements that don't match our achievement type
    	if ( ! empty( $args['achievement_type'] ) && ( $args['achievement_type'] != $achievement->post_type && ( !is_array( $args['achievement_type'] ) || !in_array( $achievement->post_type, $args['achievement_type'] ) ) ) ) unset($achievements[$key]);
    				echo '<a href="' . get_permalink( $achievement->ID ) . '">'; # let's link your users to the achievement
    				echo get_the_post_thumbnail( $achievement->ID, array(60,60) ); # display the thumbnail. We need to use the get_the_post_thumbnail function so that we can provide the appropriate ID.
    				echo '</a>';
    			}
    		}
    	}
    }
    }

    Screenshot: https://imgur.com/zqkx7Yl

Viewing 3 replies - 46 through 48 (of 48 total)