Skip to content

Instantly share code, notes, and snippets.

@gabrielmerovingi
Created March 19, 2014 11:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielmerovingi/9639469 to your computer and use it in GitHub Desktop.
Save gabrielmerovingi/9639469 to your computer and use it in GitHub Desktop.
A simple example of how you can show 5 users of each rank in your rank archive page. Remember that this code snippet goes inside the loop!
/**
* Show 5 Users of a specific rank
* This code snippet is placed inside the Loop of the archive-mycred_rank.php file
* Requires BuddyPress + myCRED 1.3+
* @version 1.0
*/
if ( function_exists( 'mycred_get_users_of_rank' ) && function_exists( 'bp_core_get_user_domain' ) ) {
$five_users = mycred_get_users_of_rank( get_the_ID(), 5 );
if ( ! empty( $five_users ) ) {
echo '<p><strong>my</strong>CRED members with this rank:</p><div class="mycred-users-of-rank">';
// mycred_get_users_of_rank will return an array of user IDs under the "user_id" key
foreach ( $five_users as $member )
echo '<a href="' . bp_core_get_user_domain( $member['user_id'] ) . '" style="display: block; float:left;">' . get_avatar( $member['user_id'], 50 ) . '</a>';
echo '</div>';
}
else {
echo '<p>There are no members with this rank.</p>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment