Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

#6524 closed enhancement (fixed)

Add filter point before group membership requests are saved

Reported by: dcavins Owned by:
Milestone: 2.4 Priority: low
Severity: minor Version: 1.0
Component: Groups Keywords: needs-patch
Cc: david.cavins@…

Description

We currently don't offer a way to prevent membership requests from being saved on a per-request basis. Say, for example, you want to add a required extended profile field, or you want to require that the "comments" field be completed before accepting the membership.

The attached patch adds a filter that fires immediately before the member is saved so that plugins can stop the process if necessary.

Please let me know if there's a smarter way to accomplish this.

Attachments (2)

6524.01.patch (2.8 KB) - added by dcavins 5 years ago.
6524.bp_groups_member.patch (946 bytes) - added by r-a-y 5 years ago.

Download all attachments as: .zip

Change History (10)

@dcavins
5 years ago

#1 @r-a-y
5 years ago

I think we should add the bail condition to BP_Groups_Member::save().

Then you could manipulate the request object on the 'groups_member_before_save' hook. See bp_groups_member.patch for what I have in mind.

#2 @r-a-y
5 years ago

  • Keywords dev-feedback added
  • Version changed from 2.3.2 to 1.0

#3 @dcavins
5 years ago

Thanks for your comments, r-a-y!

I think that your pre-save bail condition makes perfect sense in BP_Groups_Member::save(), since it would be applicable to every group membership case.

I do wonder, though, about how easy it'd be for a beginner BP-er to find it and see how it could be used to stop a request from being created (like knowing how to identify membership requests vs invitations at the groups_member_before_save filter and that emptying the user_id would then torpedo the save).

Maybe there's value to adding both approaches--the covers-every-case bail condition and the really-obviously-named filter. :)

#4 @r-a-y
5 years ago

I do wonder, though, about how easy it'd be for a beginner BP-er to find it and see how it could be used to stop a request from being created (like knowing how to identify membership requests vs invitations at the groups_member_before_save filter and that emptying the user_id would then torpedo the save).

For sure! Let's do both.

#5 @DJPaul
5 years ago

  • Milestone changed from Awaiting Review to 2.4

#6 @boonebgorges
5 years ago

In 9999:

Bail out of saving a group membership if the group_id or user_id props are not set.

In addition to basic validation, this also provides a roundabout way for
developers to noop a membership save at the 'group_member_before_save' hook.

Props r-a-y.
See #6524.

#7 @DJPaul
5 years ago

  • Keywords needs-patch added; has-patch dev-feedback removed

@dcavins is there more to do here?

#8 @dcavins
5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

@djpaul: Yes, I'd like to do more, but it can be done elsewhere. I'll close this ticket.

Note: See TracTickets for help on using tickets.