Opened 10 years ago
Closed 10 years ago
#6188 closed enhancement (fixed)
Member Types API: remove a user's member type
Reported by: | Offereins | Owned by: | boonebgorges |
---|---|---|---|
Milestone: | 2.3 | Priority: | normal |
Severity: | normal | Version: | 2.2 |
Component: | Members | Keywords: | has-patch |
Cc: | lmoffereins@… |
Description
I find myself missing a simple method for removing a certain user's member type, especially for situations where a user has multiple member types. Passing an emtpy value to bp_set_member_type()
removes *all* member types. You cannot specify which one you'd like to remove.
Attached patch introduces bp_remove_member_type( $user_id, $member_type )
, which is a possible solution that handles associated cache manipulations and hooks. This should fill the gap where plugin devs are building their own implementations. I'm not sure how this ties together with the mentioned use of bp_set_member_type( $user_id, '' )
, but it is a start.
Attachments (4)
Change History (13)
This ticket was mentioned in Slack in #buddypress by boone. View the logs.
10 years ago
#4
@
10 years ago
- Keywords needs-unit-tests removed
Offereins, boonebgorges
I think better approach here will be to use wp_remove_object_terms()
function.
6188.2.diff updates function to use this method.
#5
@
10 years ago
- Owner set to boonebgorges
- Resolution set to fixed
- Status changed from new to closed
In 9575:
Good catch, Offereins, and thanks for the patch. As a temporary workaround, you can do something like this to remove member type 'foo' but not 'bar';
The patch looks good, though I'd say that the function should return
false
if the user does not have the member type passed to the function (since nothing was deleted). This is how other WP delete functions work.Let's get some unit tests for this, and put it in for 2.3.