groups_check_user_has_invite( int $user_id, int $group_id, string $type = 'sent' )
Check to see whether a user has already been invited to a group.
Description
By default, the function checks for invitations that have been sent. Entering ‘all’ as the $type parameter will return unsent invitations as well (useful to make sure AJAX requests are not duplicated).
Parameters
- $user_id
-
(Required) ID of potential group member.
- $group_id
-
(Required) ID of potential group.
- $type
-
(Optional) Use 'sent' to check for sent invites, 'all' to check for all. Default: 'sent'.
Default value: 'sent'
Return
(int|bool) ID of the membership if found, otherwise false.
Source
File: bp-groups/bp-groups-functions.php
2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 | function groups_check_user_has_invite( $user_id , $group_id , $type = 'sent' ) { $invite = false; $args = array ( 'is_confirmed' => false, 'is_banned' => null, 'is_admin' => null, 'is_mod' => null, ); if ( 'sent' === $type ) { $args [ 'invite_sent' ] = true; } $user_groups = bp_get_user_groups( $user_id , $args ); if ( isset( $user_groups [ $group_id ] ) && 0 !== $user_groups [ $group_id ]->inviter_id ) { $invite = $user_groups [ $group_id ]->id; } return $invite ; } |
Changelog
Version | Description |
---|---|
BuddyPress 1.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.