/**
 * Return the total of all high-fives given to a particular user
 *
 * The most straightforward way to get a post count is to run a WP_Query. In your own plugin
 * you might consider storing data like this with update_option(), incrementing each time
 * a new item is published.
 *
 * @package BuddyPress_Skeleton_Component
 * @since 1.6
 *
 * @return int
 */
function bp_example_get_total_high_five_count_for_user($user_id = false)
{
    // If no explicit user id is passed, fall back on the loggedin user
    if (!$user_id) {
        $user_id = bp_loggedin_user_id();
    }
    if (!$user_id) {
        return 0;
    }
    $high_fives = new BP_Example_Highfive();
    $high_fives->get(array('recipient_id' => $user_id));
    return apply_filters('bp_example_get_total_high_five_count', $high_fives->query->found_posts, $high_fives);
}