WordPress.org

Ready to get started?Download WordPress

Forums

myCRED
[resolved] Members not able to see each others rank (5 posts)

  1. raytronx
    Member
    Posted 5 months ago #

    Using Buddypress 1.9.2 with BuddyBoss theme 3.1.4 myCred Version 1.3.3.2

    Rank set to public and set to include in Buddypress profile header.

    The rank and rank image show fine for admin and a members own profile, but members can't view each others rank when viewing another's profile.

    Is there a setting I'm missing, I can't seem to make it work?

    Thanks Ray

    https://wordpress.org/plugins/mycred/

  2. Gabriel
    Member
    Plugin Author

    Posted 5 months ago #

    Hi.

    Right now, myCRED only shows the users rank for yourself and admins. You can always add the users rank yourself via your themes functions.php file.

    First visit the myCRED > Settings page and under "Ranks" select "Do not show" for Ranks in BuddyPress.

    Then add the following piece of code to your themes functions.php file:

    add_action( 'bp_before_member_header_meta', 'mycred_insert_rank_in_profile_header' );
    function mycred_insert_rank_in_profile_header() {
    	// Leave now if myCRED is not enabled to prevent the site drom crashing
    	if ( ! function_exists( 'mycred_exclude_user' ) ) return;
    
    	// Get the displayed users ID
    	$user_id = bp_displayed_user_id();
    
    	// Make sure this user is not excluded from using myCRED
    	if ( mycred_exclude_user( $user_id ) ) return;
    
    	// Get the rank name
    	$rank_name = mycred_get_users_rank( $user_id );
    
    	// Optionally also get the rank logo
    	$rank_logo = mycred_get_rank_logo( $rank_name );
    
    	// Finally show it all
    	echo '<div id="mycred-my-rank">Rank: ' . $rank_name . ' ' . $rank_logo . '</div>';
    }

    In the above example I am showing both the rank name and the rank logo. You can find more information about these functions in the myCRED Codex.

    mycred_get_users_rank
    mycred_get_rank_logo

  3. raytronx
    Member
    Posted 5 months ago #

    Excellent, thanks so much for the code.

    My wife is using myCred on her site and for some reason it works without adding code to the functions.php. Her members can see each others Rank and rank logos in each others profiles. Her site was has a custom built theme though and is quite different than mime with BuddyBoss. Anyway thanks again. Great Plugin!

    Cheers Ray

  4. Gabriel
    Member
    Plugin Author

    Posted 5 months ago #

    Hi.

    Very odd. Maybe your theme does show the ranks but it is styled away or hidden? myCRED uses standard BuddyPress hooks to insert information in specific places and most themes that have BuddyPress support would include this hook but maybe yours do not. The above code can be used in other BuddyPress hooks as well in case you do not want to show the rank in the profile header but maybe some other place in the profile.

  5. raytronx
    Member
    Posted 5 months ago #

    I followed your directions in this thread and it is working perfect on my site now and doing what I want which is the Rank and Rank Image viewable by anyone on any members profile page.

    I did add a bit of CSS to line the logo up with text in the middle.

    #mycred-my-rank img{vertical-align:middle}

    Thanks for the help, appreciate it.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags