Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active March 6, 2024 21:25
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 KaineLabs/b18d492fed78069651c40b0a69c3f7ce to your computer and use it in GitHub Desktop.
Save KaineLabs/b18d492fed78069651c40b0a69c3f7ce to your computer and use it in GitHub Desktop.
Show User Rank on Profile Header
<?php
/**
* Show User Rank on Profile Header.
*/
function yzc_add_user_rank_in_header() {
if ( function_exists( 'mycred_get_users_rank' ) ) {
// Get rank object
$rank = mycred_get_users_rank( bp_displayed_user_id() );
// If the user has a rank, $rank will be an object
if ( is_object( $rank ) ) {
// Rank Logo
$rank_logo = ( $rank->has_logo ) ? $rank->get_image( 'logo' ) : '<i class="fas fa-user"></i>';
// Show rank title
echo '<div class="yz-user-level-data"><i class="fa fa-user" aria-hidden="true"></i><span style="width:40px;">' . $rank_logo . '</span><span class="yz-user-level-title">'. __( 'Rank : ', 'youzer' ) . $rank->title . '</span></div>';
}
}
}
add_action( 'yz_after_profile_header_user_meta', 'yzc_add_user_rank_in_header' );
@cryptojasonnl
Copy link

Is there are snippet to do exactly this but than with the use of Gamipress ranks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment