#7397 closed enhancement (fixed)
groups_send_invites() should allow us to omit sending to users that have already received an invite
Reported by: | r-a-y | Owned by: | r-a-y |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Groups | Keywords: | has-patch |
Cc: |
Description (last modified by )
<?php
groups_send_invites()
is the function that handles sending group invites.
In that function, there is a call to groups_get_invites_for_group()
. This function determines what users to send an invite to.
However, groups_get_invites_for_group()
doesn't allow us to check if we have already sent an invite to that user due to a lack of check for invite_sent = 1
.
Attached patch allows for this and includes unit tests.
Note: I have not changed the default logic of groups_send_invites()
to omit sending to those we have already sent invites to. However, we can if we want to.
Attachments (1)
Change History (10)
#3
@
8 years ago
I assume you added this param to maintain compatibility with the current behavior.
You assume correctly!
Members with invite_sent=1 will be passed to groups_notification_group_invites(), but that function bails immediately for memberships with invite_sent=1.
Good catch. Was writing this patch and ticket late at night and I completely missed this.
What do you think about using your continue
approach? And also taking parts of the groups_get_invites_for_group()
and BP_Groups_Group::get_invites()
mods from 01.patch
?
#4
@
8 years ago
- Description modified (diff)
What do you think about using your continue approach? And also taking parts of the groups_get_invites_for_group() and BP_Groups_Group::get_invites() mods from 01.patch?
Sure, that seems reasonable. The changes from 01.patch wouldn't be used in this specific fix, but they could definitely be useful for developers down the road.
#5
@
8 years ago
The other use case is being able to resend invitations in specific instances. In some old patches, I went the other way and added a force_send
parameter to groups_notification_group_invites()
.
I think @r-a-y's suggested parameter to filter invitations by sent status is a useful improvement to the fetch functions.
Thanks for opening this ticket, @r-a-y.
Under what circumstances would one want
$omit_sent = false
? I assume you added this param to maintain compatibility with the current behavior. But the current behavior may not be worth preserving. Here's what happens in the loop:Members with
invite_sent=1
will be passed togroups_notification_group_invites()
, but that function bails immediately for memberships withinvite_sent=1
. Setting$member->invite_sent = 1
obviously does nothing. So the only things that actually happen for these members is that (a) theBP_Group_Member::save()
hooks fire, and (b) the already-invited users are passed to thegroups_send_invites
filter.What if we simply do something like this:
This preserves behavior (b) (the values passed to the filter). It changes (a), but (a) is sorta semantically incorrect anyway - no change has been made, so why fire the
save
actions? - and it's hard to imagine any real-world compatibility breaks.What do you think?