BP_Groups_Member::check_has_invite( int $user_id, int $group_id, string $type = 'sent' )
Check whether a user has an outstanding invitation to a given group.
Description
Parameters
- $user_id
-
(Required) ID of the potential invitee.
- $group_id
-
(Required) ID of the group.
- $type
-
(Optional) If 'sent', results are limited to those invitations that have actually been sent (non-draft). Default: 'sent'.
Default value: 'sent'
Return
(int|null) The ID of the invitation if found; null if not found.
Source
File: bp-groups/classes/class-bp-groups-member.php
public static function check_has_invite( $user_id, $group_id, $type = 'sent' ) {
global $wpdb;
if ( empty( $user_id ) )
return false;
$bp = buddypress();
$sql = "SELECT id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d AND is_confirmed = 0 AND inviter_id != 0";
if ( 'sent' == $type )
$sql .= " AND invite_sent = 1";
$query = $wpdb->get_var( $wpdb->prepare( $sql, $user_id, $group_id ) );
return is_numeric( $query ) ? (int) $query : $query;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 1.6.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.