BuddyDev

Search

How can I Get Buddypress Favorite Count

  • Inactive
    Level: Enlightened
    Posts: 28
    Kikismedia on #30725

    I want to get buddypress favorite count and mention count to display on my theme header how can I get this done

  • Keymaster
    (BuddyDev Team)
    Posts: 24642
    Brajesh Singh on #30727

    Hi Adeala,
    You can get the total favourite count using this function

    
    $count = bp_activity_total_favorites_for_user( $user_id );
    

    where you need to provide the $user_id for the context.

    For example, to get total favourite count for logged in user, we can use

    
    
    $count = bp_activity_total_favorites_for_user( get_current_user_id() );
    
    

    If you are on a user profile and want to fetch the total count of the displayed user, you can do it like this

    
    $count = bp_activity_total_favorites_for_user( bp_displayed_user_id() );
    
    

    Hope that helps.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved