Last active
March 6, 2024 21:25
-
-
Save KaineLabs/b18d492fed78069651c40b0a69c3f7ce to your computer and use it in GitHub Desktop.
Show User Rank on Profile Header
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there are snippet to do exactly this but than with the use of Gamipress ranks?