BP_REST_Group_Membership_Request_Endpoint:: delete_item (WP_REST_Request美元的请求)
拒绝一个待处理的组成员请求。
描述
参数
- 美元的请求
-
(WP_REST_Request)(必需)关于请求的完整数据。
返回
(WP_REST_Response)| WP_Error
源
文件:bp-groups /类/ class-bp-rest-group-membership-request-endpoint.php
public function delete_item($request){//设置上下文。$request->set_param('context', 'edit');/ /得到邀请。$this->fetch_single_membership_request($request['request_id']); / /用户名//在删除之前设置邀请响应。$previous = $this->prepare_item_for_response($group_request, $request);/** *如果这个更改是由请求用户发起的,*使用' delete '函数。*/ if (bp_loggedin_user_id() === $group_request->user_id) {$success = group_delete_membership_request (false, $group_request->user_id, $group_request->item_id);/** *否则,这个更改是由组管理员或站点管理员发起的,*我们应该使用'拒绝'功能。*/} else {$success = group_reject_membership_request (false, $group_request->user_id, $group_request->item_id); } if ( ! $success ) { return new WP_Error( 'bp_rest_group_membership_requests_cannot_delete_item', __( 'There was an error rejecting the membership request.', 'buddyboss' ), array( 'status' => 500, ) ); } // Build the response. $response = new WP_REST_Response(); $response->set_data( array( 'deleted' => true, 'previous' => $previous->get_data(), ) ); $user = bp_rest_get_user( $group_request->user_id ); $group = $this->groups_endpoint->get_group_object( $group_request->item_id ); /** * Fires after a group membership request is rejected via the REST API. * * @param WP_User $user The user. * @param BP_Groups_Group $group The group object. * @param WP_REST_Response $response The response data. * @param WP_REST_Request $request The request sent to the API. * * @since 0.1.0 */ do_action( 'bp_rest_group_membership_requests_delete_item', $user, $group, $response, $request ); return $response; }
更新日志
版本 | 描述 |
---|---|
0.1.0 | 介绍了。 |