Search code examples
phpwordpressbuddypress

Buddypress Activity issue & cubepoints


i currently encounter a problem in the activity i was adding to each user to be displayed its cubepoint rank i have added the following

<?php echo cp_module_ranks_getRank( bp_displayed_user_id() ); ?>

but it dosent seem to work it seems to repeat the same rank on each user again and again it stays in level 1 also i have applied that same code.

i posted above and it works for each users profile so it displays there actual rank so its weird i will be posting an image of what i mean, thank you have a nice day.


Solution

  • bp_displayed_user_id() is used on a member profile page to determine the ID of the user's profile currently being shown, but it won't update when part of the loop. Depending on which type of loop you are using, you need to use one of the following methods:

    For the activity loop, the function would be bp_get_activity_user_id() to return the ID and bp_activity_user_id() to echo it. For you case you would want to use:

    <?php echo cp_module_ranks_getRank( bp_get_activity_user_id() ); ?>
    

    In the case of the member loop, the function would be bp_get_member_user_id() to return the ID and bp_member_user_id() to echo it:

    <?php echo cp_module_ranks_getRank( bp_get_member_user_id() ); ?>