BP_Groups_Member::get_invite_count_for_user( int $user_id )

Gets the total group invite count for a user.

Description

Parameters

$user_id

(Required) The user ID.

Return

(int)

Source

File: bp-groups/classes/class-bp-groups-member.php

826
827
828
829
830
831
832
833
834
835
836
837
838
839
public static function get_invite_count_for_user( $user_id = 0 ) {
    global $wpdb;
 
    $bp = buddypress();
 
    $count = wp_cache_get( $user_id, 'bp_group_invite_count' );
 
    if ( false === $count ) {
        $count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(DISTINCT m.group_id) FROM {$bp->groups->table_name_members} m, {$bp->groups->table_name} g WHERE m.group_id = g.id AND m.is_confirmed = 0 AND m.inviter_id != 0 AND m.invite_sent = 1 AND m.user_id = %d", $user_id ) );
        wp_cache_set( $user_id, $count, 'bp_group_invite_count' );
    }
 
    return $count;
}

Changelog

Changelog
Version Description
BuddyPress 2.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.